ESRI has chosen Python as it's one and only programming language for the ArcGIS software packages. There is also no upgrade path from the previous languages (Command line, VBA, VB, and MapObjects). This means all your scripts will have to be rewritten to Python. The good new is that Python is supported throughout the ArcGIS products and is well documented (with a few problems).
Note: MapAlgebra still exists within the raster calculator and you can use either Python or VBScript in the field calculator.
There are four ways of writing Python scripts that we'll be talking about:
The Python window in ArcGIS is the easiest way to get started accessing functions within ArcGIS but it is really challenging to learn the Python language and write script longer than a few lines in this window. The Python GUI is better but the Wingware IDE is a full Integrated Development Environment. All of these approaches allow you to access ArcGIS functions.
Note: If you use Wingware or any other software that does not come with ArcGIS you may need to set the path to the correct Python executable. This will be in "c:\Python26\ArcGIS 10...\" and is the "python.exe" file.
Feature | Python Window (IDLE) | IDLE (Python GUI) | PythonWin | Wingware |
---|---|---|---|---|
Comes with ArcGIS | Yes | Yes | No | $49.00 for personal version |
Integrated into ArcGIS | Yes | No | No | No |
Code-Completion Help | Yes | ? | ? | Yes, after "import" |
Command line window | Yes | Yes | Yes | Yes |
Executes scripts from files | No | Yes | Yes | Yes |
Debugging Mode | No | Yes? | Yes? | Yes |
Breakpoints | NA | Yes? | Yes? | Yes |
Displays Variables | NA | No? | Sort of? | Yes |
Stack Traces | NA | No? | No? | Yes |
There are also other options for writing Python code:
We recommend the following approach to creating Python scripts:
The other recommendation is that you start a document that contains the functions and "code snippets" that you use commonly. This can be a handy reference for you and can be used to save snippets and functions you might use in the field calculator.
There is a lot of help provided in ArcGIS for Python.
During each lesson we'll show you how to use these help resources to make learning Python in ArcGIS easier.
There are also a lot of resources available on the Internet for learning Python outside of ArcGIS. Unfortunately, at this time, there are no books or good web resources for using Python with ArcGIS outside of the ESRI resources. Python in ArcGIS is new so I expect we'll start seeing a broader base of information for Python in ArcGIS. Please let me know if you find good resources and I'll add them to the website.
ArcGIS installs it's own version of Python at "C:/Python26/ArcGIS10.0. This version is not compatible with some Python packages like "JPype".
© Copyright 2018 HSU - All rights reserved.