GEOG 485:
GIS Programming and Software Development

1.3.4 Advanced geoprocessing and ModelBuilder concepts


By now, you've had some practice with ModelBuilder, and you're about ready to get started with Python. This page of the lesson contains some optional advanced material that you can read about ModelBuilder. This is particularly helpful if you anticipate using ModelBuilder frequently in your employment. Some of the items are common to the ArcGIS geoprocessing framework, meaning that they also apply when writing Python scripts with ArcGIS.

Managing intermediate data

GIS analysis sometimes gets messy. Most of the tools that you run produce an output dataset, and when you chain many tools together, those datasets start piling up on disk.  Esri has programmed ModelBuilder's default behavior such that when a model is run from a GUI interface, all datasets besides the final output -- referred to as intermediate data -- are automatically deleted.  If, on the other hand, the model is run from ModelBuilder, intermediate datasets are left in their specified locations.

When running a model on another file system, specifying paths as we did above can be problematic, since the folder structure is not likely to be the same.  This is where the concept of the scratch geodatabase (or scratch folder for file-based data like shapefiles) environment variable can come in handy.  A scratch geodatabase is one that is guaranteed to exist on all ArcGIS installations.  Unless the user has changed it, the scratch geodatabase will be found at C:\Users\<user>\Documents\ArcGIS\scratch.gdb on Windows 7/8.  You can specify that a tool write to the scratch geodatabase by using the %scratchgdb% variable in the path.  For example, %scratchgdb%\myOutput.

The following topics from Esri go into more detail on intermediate data and are important to understand as you work with the geoprocessing framework. I suggest reading them once now and returning to them occasionally throughout the course. Some of the concepts in them are easier to understand once you've worked with geoprocessing for a while.

Looping in ModelBuilder

Looping, or iteration, is the act of repeating a process. A main benefit of computers is their ability to quickly repeat tasks that would otherwise be mundane, cumbersome, or error-prone for a human to repeat and record. Looping is a key concept in computer programming, and you will use it often as you write Python scripts for this course.

ModelBuilder contains a number of elements called Iterators that can do looping in various ways. The names of these iterators, such as For and While actually mimic the types of looping that you can program in Python and other languages. In this course, we'll focus on learning iteration in Python, which may actually be just as easy as learning how to use a ModelBuilder iterator.

To take a peek at how iteration works in ModelBuilder, you can visit the ArcGIS Pro ModeBuilder help book for model iteration. If you're having trouble understanding looping in later lessons, ModelBuilder might be a good environment to visualize what a loop does. You can come back and visit this book as needed.



ArcGIS Pro edition:

Read Zandbergen Chapter 3.1 - 3.6, and 3.8 to reinforce what you learned about geoprocessing and ModelBuilder. 

ArcMap edition:

Read Zandbergen Chapter 2.1 - 2.2, 2.4 - 2.7, and 2.9 to reinforce what you learned about geoprocessing and ModelBuilder.  As you read, please note the following ArcMap/ArcGIS Pro differences:

  • Section 2.4 talks about using the Search window to search for tools by name.  The comparable feature in Pro can be found by going to Analysis > Tools to open the Geoprocessing pane.  The top of this pane has a Find Tools box.
  • Section 2.6 discusses tool dialog boxes.  Differences of note in Pro:
    - Tool dialogs always open within the Geoprocessing pane, not hovering above the application window. 
    - Instead of a help panel that can be revealed/hidden, clicking the ? icon in the upper right opens the online Help system page for the tool in your default web browser.  
    - Required parameters are denoted by a red asterisk rather than a green dot.
    - Selecting Analysis > History provides a list of previously run tools, comparable to the Results window in ArcMap.
    - The option for overwiting geoprocessing results is found under Project > Options > Geoprocessing > Allow geoprocessing tools to overwrite existing datasets.  Note that this option is checked by default in Pro, the opposite of the default setting in ArcMap.
  • Section 2.7 discusses environment settings.  Application-level environment settings can be found in Pro by going to Analysis > Environments.