How you build models and use python with ArcGIS Pro is slightly different from ArcMap. This blog aims to help you migrate your models and scripts for use in ArcGIS Pro.
We’ve shared several blogs aimed at helping you migrate from ArcMap to ArcGIS Pro. A particular favourite is Tips and tricks for transitioning from ArcMap to ArcGIS Pro. This introduces you to some of the basics including projects, symbology, network analysis and links to a quick-start tutorial.
Assessing the situation
ModelBuilder in ArcGIS Pro is fundamentally very similar to ModelBuilder in ArcMap. The model appearance is similar, and you still build models by adding data and geoprocessing tools and connecting them to form a workflow.
There are some differences, however you should find most models built using ArcMap will run without any conversion.
If not, then help is on hand – ArcGIS Pro comes with a geoprocessing tool called Analyse Tools for Pro (Data Management Tools > General). This tool uses the Python utility 2to3 to identify issues when migrating a script and even goes so far as to identify functionality that has not been migrated to ArcGIS Pro. Running this tool will generate an output for you that will state which lines have errors and suggest appropriate changes which you can manually assess. Often the required changes are small and can be made quickly.
Before opening or editing a model in ArcGIS Pro ModelBuilder it is recommended that you make a copy of the original toolbox. If you edit and save the model in ArcGIS Pro, that copy of the model will not be useable in other ArcGIS Desktop applications.
Models that are newly created, as well as any models that have been edited and saved in ArcGIS Pro ModelBuilder, can be used in other ArcGIS Desktop applications by saving the toolbox to a new toolbox of the correct version. Right-click any toolbox, select Save As, then select the version.
The majority of geoprocessing tools will continue to be available in ArcGIS Pro however, some tools will not. For a full listing, see the list of tools not supported in ArcGIS Pro.
Python scripts built in ArcMap that use tools not available in ArcGIS Pro do not function and require updates.
Let’s start by looking at a script created in ArcMap.
This very simple script sets the workspace to the Demos file geodatabase (FGDB) and then uses the ListFeatureClasses() function to iterate through the FGDB, looking for all the feature classes within and then prints a list on the screen. Like so….
Notice that the release of Python is the 2.7.x release – this is the release of Python that is installed with ArcMap.
Now let’s run the Analyse Tools for Pro tool to discover whether this script is compatible with ArcGIS Pro (which uses the 3.x release of Python).
You can easily find the tool by clicking the Analysis tab and the Tools button on the ribbon, then type analyse. In the Analyse Tools for Pro pane add the python script to analyse and an output file for the results.
Now we are getting to the exciting bit…..
After running the tool, I was informed that the tool completed successfully but with warnings. By viewing the details, I was able to discover what needed to be fixed in the script.
This wasn’t a complicated script, and I could work out the changes pretty easily, but for more complex and larger scripts I would use the Results.txt file generated by the tool to help resolve any compatibility issues.
To read more about python migration tips click here.
Straight to it, I’m not a python developer, ‘what’ I hear you cry, yes, I know…. but even simple scripts written by non-developers may have compatibility issues and using this tool really helps identify and resolve ‘little’ challenges too.
So, what are you waiting for, get those python scripts migrated to ArcGIS Pro.