The Importance of Automation in Mapping
A geographic information system (GIS) can be used to display spatial data, as well as to analyze and manipulate that data to solve problems. ESRI’s ArcGIS software and Python can be used to solve geographic problems. Python is a free, open-source programming language used to create scripts used in conjunction with ArcGIS. Read What is Python? for additional information.
It is assumed that you have some background and understanding in basic geoprocessing, GIS operations used to manipulate spatial data including buffering, clipping, and merging data sets. Read What is geoprocessing? to review how geoprocessing tools such as Project and Clip can be used to sequence tools to automate work and solve problems.
Perhaps you need to classify certain soil types along a river in a community to provide inputs for a model. You may not need all the detailed types available, so you merge similar types based on the attribute, buffer the river and clip it with both the community polygon and river buffer. It makes sense to do this manually for a single dataset, but if this needs to be run multiple times in many different areas, the process could be automated in several different ways to make the process easier, less prone to error, and faster. It does take extra time to set up the automated process, test it to make certain that it gives the correct results, and solve problems that may show up when running a process on a wide variety of inputs. This does present a trade-off which needs to be weighed when deciding whether to automate a process. Once you are familiar with automating tasks, it may be worthwhile to automate the process even if it will only be done two or three times.
There are several ways to automate a tool for multiple inputs in ArcGIS:
- Create a batch process by right-clicking on a tool and choosing batch process. This works well when only a single tool needs to be run on many different inputs. The output of one tool is used as the input to the second tool.
- Use ModelBuilder to create a sequence of tools.
- Run Python scripts to run a tool automatically or as part of a sequence of tools.
- Write a program in ArcObjects directly, that uses the same building blocks employed by ESRI developers.
The Essential Python Vocabulary describes the terminology used to understand geoprocessing with Python.
The ArcGIS Console is a good place to start learning some python for GIS. It runs each line of code as it is entered providing immediate feedback and helps on python commands specific to GIS.
Select the Python icon shown in Figure 1 or select Geoprocessing > Python from the menu bar to open the Python Window in ArcGIS.
Figure 1: ArcGIS Menubar
The command prompt is shown below in Figure 2.
Figure 2: ArcGIS Console
A great feature of the console is that you can type a variable name and it will display the current value immediately on the next line before it again shows the prompt (>>>).