Finding additional Python examples

There are many examples of using Python to coordinate and execute geoprocessing tools available in the scripting help. Many of these examples focus on the use of specific methods or properties of the geoprocessor and are intended to be concise and easy to follow. More detailed and sometimes complicated examples of how to use Python to solve problems can be found as tools in ArcGIS. While most tools delivered with ArcGIS are written in C++ and delivered in a binary form, some are written in Python or ModelBuilder. Some tools execute batch operations, such as loading data into a geodatabase or projecting a set of feature classes, which is perfectly suited for scripting as the solution. The underlying script can be opened at any time to see what happens when the tool is run. Use this capability to learn how to use arcpy in a number of situations, such as creating multiple ring buffers or building pyramids for a set of rasters. Script tools have a unique icon A script icon so you can easily find tools that use scripts to execute. Use the edit option in a tool's context menu to open and examine the underlying script.

These scripts cannot be edited, as they are read-only, but you can copy the tool to a custom toolbox and its underlying script to another folder so you can make edits if desired.

The help for each geoprocessing tool also contains a section specific to scripting, with a description of each parameter and an example of how to use the tool in a Python script.

NoteNote:

Any model created in ModelBuilder can be exported to a Python script. This can be one technique for furthering your model as well as seeing how tools and environments are used in Python.

Additional scripting samples

For information on a particular geoprocessing tool, see the online geoprocessing command reference or click the Help button on a geoprocessing tool's dialog box. An explanation of each parameter and example scripting code is provided.

User-created Python scripts can be found on the Geoprocessing Resource Center Tool Gallery.

Python-specific help can be found on the Python website.

Related Topics

4/16/2013