Executing geoprocessing tools from a script
Once you have determined the toolbox alias and then verified the accessibility of the tool based on your current license level, you are ready to add the execution of the tool to a script.
Getting ready
Now that you understand how to find the tools that are available and how to uniquely reference them, the next step is to put this together and execute a tool from a geoprocessing script. In this recipe, you can then execute the tool from your script.
How to do it…
Open
C:\ArcpyBook\Ch6\Crime_Ch6.mxd
in ArcMap.Click on the Add Data button and add the
EdgewoodSD.shp
file to the table of contents.Turn off the Crime Density by School District and Burglaries in 2009 layers to get a better view of the EdgewoodSD layer. There is only one polygon feature in this file. It represents the Edgewood School District. Now we're going to write a script that clips the Burglaries in 2009 features to this school district.
Open the Python window in ArcMap.
Import the
arcpy...