Iterating in ModelBuilder

One of the most exciting new features in ArcGIS 10 is the introduction of iterating tools in ModelBuilder.  The ability to step through a list has always been a mainstay of programming and computer science, and has been readily accessible to any GIS programmer with a little Python or C# experience.  In previous versions of ModelBuilder, iteration was possible through the clever use of count variables and batch processing.  But now it is available graphically on the desktop, and can be added to a model with a single click.

To illustrate, consider the following example.  We begin with 2 files, a set of building footprints (derived from LIDAR), and a collection of census block groups.  In order to determine the built-up density of each block, we need to determine which of the building footprints are in each block, and then calculate the total building area.  To accomplish this, we need to step through each block, extract (Select) it from the dataset, and then use it to Clip the building footprints.  Then we can use Summary Statistics to sum the building area.  I’d also like to add the block group ID as a field in the statistics file, for later reference, and this can be done with calls to Add Field and Calculate Field.

Although it sounds difficult on paper, this is a fairly typical task for ModelBuilder.  There are only 5 actions, and the workflow is largely linear.  The trouble is that we want to do this 516 times!  This is where iterations become handy.  One of the iteration methods, “Iterate Field Values” allows you to step over each row in a field and pass the value of the field as a variable.  In my example, the variable holding the block group ID is simply called Value, and I can reference it anywhere in my model by calling %Value%:

Click the image to view a larger version

Notice in the above graphic that the iteration is not attached to the main workflow.  Instead, it appears to run parallel.  Although this notation may seem bizarre to seasoned programmers, I assure you that it is identical to the behavior of a typical for-each loop.

At this time, only one iteration can be used for each model.  For more information about how to use iterations, check out the online help.

Comments are closed.