You are here:
Geoprocessing
>
Automating your work with scripts
>
Getting started with writing geoprocessing scripts
Note:
This topic was updated for 9.3.1.
ArcGIS 9 includes scripting support for many of today's most popular scripting environments such as Python, VBScript, JScript, and Perl. A new ArcObjects component, the geoprocessor, manages all the geoprocessing functions available within ArcGIS. It is an object that provides a single access point and environment for the execution of any geoprocessing tool in ArcGIS, including extensions. The geoprocessor implements automation via a coarse-grained scripting object. This scripting object can be created in three different ways at 9.3:
- Using the native arcgisscripting module, setting a 9.3 version
import arcgisscripting
gp = arcgisscripting.create(9.3)
Using the native arcgisscripting module
import arcgisscripting
gp = arcgisscripting.create()
Using COM IDispatch interface
import win32com.client
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
NOTE: In order to use the win32com.client module successfully, PythonWin should be be installed. For more information on installing PythonWin, see Installing PythonWin.
Learn more about creating the geoprocessor object
The geoprocessor makes it possible for interpretive and macro languages to access the more than 500 available tools.
Although there are a number of good scripting languages available, for simplicity, three of the more popular languages that meet the necessary criteria—VBScript, JScript, and Python—are discussed. VBScript and JScript are familiar to many people and are relatively simple languages. Similar to Visual Basic and C, they are designed to operate in a Windows environment. Python is an easy-to-learn language similar to C. Python has the ease of use of a scripting language, along with the programming capabilities of a complete developer language. Moreover, Python is platform independent and can operate on a variety of operating systems including UNIX, Linux, and Windows. For more information, visit
www.python.org on the Web.
ESRI sees Python as the language that fulfills the needs of our user community. Some advantages of Python are as follows:
- Python is simple to learn because of its clean syntax and simple, clear concepts.
- Python supports object-oriented programming in an easy-to-understand manner.
- Documenting Python is easy because it has readable code.
- Complicated data structures are straightfoward to work with in Python.
- Python is simple to integrate with C++ and Fortran.
- Python can be seamlessly integrated with Java.
- Python is free from the Web and has a widespread community.
Learn more about using the geoprocessor
Please visit the
Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.