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. Even if you're diligent about naming your datasets intuitively, it's easy to wind up with a folder full of datasets with names like buffers1, clippedbuffers1, intersectedandclippedbuffers1, raster2reclassified, etc.
In most cases, you are concerned with just the final output dataset. The intermediate data is just temporary; you only need to keep it around for as long as it takes to run the model, and then it can be deleted.
ModelBuilder can manage your intermediate data for you, placing it in a temporary directory called the scratch workspace. By default, the scratch workspace is your operating system's temp directory, but you can configure it to exist in another location.
You can force data to go into the scratch workspace by using the %SCRATCHWORKSPACE% variable in the path. For example: %SCRATCHWORKSPACE%\myOutput.shp
You can also mark any element in ModelBuilder as Intermediate and it will be deleted after the model is run. By default, all derived data is Intermediate.
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.
- A quick tour of managing intermediate data
- Using the current and scratch workspace environments
- Managing intermediate (scratch) data in shared model and script tools (Skip the section about ArcGIS Server)
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 Desktop 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.
Read Zandbergen Chapter 2.1 - 2.9 to reinforce what you learned about geoprocessing and ModelBuilder.