- Support Home >
- Knowledge Base >
- Technical Articles >
- Article Detail
HowTo: Get started writing Python geoprocessing scripts in ArcGIS 9x
| Article ID: | 30028 |
|---|---|
| Software: | ArcGIS - ArcEditor 9.0, 9.1 ArcGIS - ArcInfo 9.0 ArcGIS - ArcView 9.0, 9.1 |
| Platforms: | Windows 2000, XP |
Summary
Instructions provided describe the resources available to help get started using Python scripting for geoprocessing.
Procedure
- Read the 'Writing Geoprocessing Scripts' PDF white paper. This is located on the ESRI Library CD and is entitled Writing_Geoprocessing_Scripts.pdf. This PDF provides an overview of writing geoprocessing scripts.
- Print the Geoprocessing Object Model; a link to this model is located in the ArcGIS Desktop Help.
-show me- 1. Start the ArcGIS Desktop Help by navigating to Start > Programs > ArcGIS > ArcGIS Desktop Help, or select Help from within ArcMap or ArcCatalog.
2. In ArcGIS Desktop Help, select the Contents Tab and then navigate to Geoprocessing > Automating your work with scripts > Scripting Object: Properties and Methods. Select Geoprocessor programming model. - Details and samples for all the Scripting Object properties and methods can be found in the ArcGIS Desktop Help.
-show me- 1. Start the ArcGIS Desktop Help by navigating to Start > Programs > ArcGIS > ArcGIS Desktop Help, or select Help from within ArcMap or ArcCatalog.
2. In ArcGIS Desktop Help, select the Contents Tab. Navigate to Geoprocessing > Automating your work with scripts > Scripting Object: Properties and Methods. Select Properties and Methods. - There are several places to find Python syntax for each geoprocessing tool:
• Quick reference guide located on the ESRI Library CD entitled Geoprocessing_Quick_Ref_Gde.pdf.
• More detailed information and samples for each geoprocessing tool can be found in the ArcGIS Desktop Help.-show me- 1. Start the ArcGIS Desktop Help by navigating to Start > Programs > ArcGIS > ArcGIS Desktop Help, or select Help from within ArcMap or ArcCatalog.
2. In ArcGIS Desktop Help, select the Contents Tab > Geoprocessing Tool Reference.
Here is located a subtopic for each toolbox in ArcToolBox containing sub topics for each toolset. Within each toolset subtopic, there is a tool subtopic with documentation and Python samples for each tool. - Since Python is not an ESRI product, it is recommended use non-ESRI resources such as Python's website, www.Python.org, and the 'Python in a Nutshell' and the 'Learning Python' books published by O'Reilly. Essential non-ESRI Python syntax is also described in the "Writing Geoprocessing Scripts" pdf.
- Knowing how to export a model to a script is very useful.
-show me- 1. Create models to do some or all of what the scripts do.
2. Export the model to a Python script and the Python code is essentially written automatically.
3. Open the script in PythonWin to make modifications it. For example, adding looping and conditional statements.
Another reason to know how to export models to scripts is to see the correct syntax for tools. Export a model to a script from within the model builder window. Click Model > Export > To Script > Python. - One of the most common tasks is to repeat run a geoprocessing operation. See the link in the Related Information section below.
- Additional training is available from ESRI and ESRI-authorized instructor-led classes as well as by way of the ESRI Virtual Campus. See the link in the Related Information section below for more information about ESRI Training and Events.
Related Information
- ESRI Demo: Advanced Python Demos and Slides Toolbox
- Use scripting in ArcGIS Desktop to run custom tools and repetitive geoprocessing workflows and tasks
A variety of scripting languages are supported in the geoprocessing environment of ArcGIS 9.0 Desktop, including Python, VBScript, JScript, and Perl, which provide the ability to run custom tools batch style. Any scripting language that is COM com... - ESRI Training & Events
Created: 11/29/2005
Last Modified: 1/4/2010