Executing tools from a script
As an ArcGIS user, you have almost certainly used the many available tools in ArcToolbox to accomplish your geoprocessing tasks. Some examples include Clip, Buffer, Feature Class to Feature Class, Add Field, and many more. Your scripts can execute any of the tools found in ArcToolbox. Remember that the tools available to you as a programmer are dependent upon the license level of ArcGIS Destkop that you are using. These tasks can be automated through the creation of a Python script that executes these tools programmatically.
How to do it…
Follow these steps to learn how to execute a geoprocessing tool from your script. Open c
:\ArcpyBook\Ch2\TravisCounty.mxd
with ArcMap.Open the Python window.
Import the
arcpy
package:import arcpy
Set the workspace. We haven't discussed the
env
class yet. Environment settings for ArcGIS are exposed as properties of thisenv
class, which is a part ofarcpy
. One of the properties of theenv
class is workspace, which defines the current...