Examples of using iterators in ModelBuilder

For

To understand the use of the For tool, see the illustration below, where the For iterator iterates from a value of 500 to a value of 2000, increasing by increments of 500. The output of For is used as the Buffer Distance parameter in the Buffer tool and in the output name as in-line variable substitution.

Use of For in ModelBuilder

Iterate Feature Selection

To understand the use of Iterate Feature Selection in ModelBuilder, see the illustration below, where the model calculates how much of the East Coast land-cover map area was destroyed by a 100-meter swath of five category 1 hurricanes. The Input Feature variable is a feature class of five Atlantic hurricane paths with a 100-meter buffer around it. The Input Raster variable is a land-cover raster.

In this example, the name of the hurricane has been used as a grouping field to make the selection, and the selected feature is used as the input for the Zonal Statistics As Table tool to generate an output table with statistics on the land cover destroyed during the hurricanes' landfall.

The Iterate Feature Selection tool has two outputs:

How to use Iterate Feature Selection

Iterate Row Selection

To understand the use of Iterate Row Selection in ModelBuilder, see the illustration below, where the model creates a deviational ellipse for theft incidents during different periods of the day—morning, afternoon, evening, and night—to detect an underlying pattern of crime.

The Input Feature Class variable is a feature class containing vandalism incident points. It contains the field Crime_Peri (crime period), which is the time of day the incident occurred (the strings Morning, Afternoon, Evening, and Night). This field is used as the grouping field to make the selection, and the selected rows are used to create an output standard deviational ellipse.

The tool has two outputs:

How to use Iterate Row Selection

Iterate Field Values

To understand the use of Iterate Field Values in ModelBuilder, see the illustration below, where the model runs Cluster And Outlier Analysis for the number of people below the poverty line in each county to compare the results at different distances. These distances are recorded as the Distance field in the Input Table variable.

Note that on the Iterate Field Values dialog box, the Unique Values option is checked by default to iterate over each unique value in a table. Unchecking the Unique Values option will iterate for each value in the field, and the output value will be repeated if there are duplicate values in the input field.

Iterate Field Values has one output: the value of the field, which is used as the Distance Band or Threshold distance parameter of the Cluster And Outlier Analysis tool. The Value variable is also used to construct the output file name of the Output Cluster Feature Class variable with the use of in-line variable substitution.

How to use Iterate Field Values

Iterate Multivalue

To understand the use of Iterate Multivalue in ModelBuilder, see the illustration below, where the model changes the map projection of several feature classes stored in different drives and workspaces. The projected output feature classes are written to a single output database.

The tool has one output: the value, which is a string of feature classes connected to the Project tool as input.

How to use Iterate Multivalue

Iterate Datasets

To understand the use of Iterate Datasets in ModelBuilder, see the illustration below, where the model copies all the feature datasets contained in the Input Dataset variable, a workspace variable. The iteration has been restricted to iterate only on the FEATURE dataset type.

The tool has two outputs:

How to use Iterate Datasets

Iterate Feature Classes

To understand the use of Iterate Feature Classes in ModelBuilder, see the illustration below, where the model finds the population density for the Block and Parcel feature classes in the Input Feature Classes variable.

The iteration has been restricted by choosing the POLYGON feature type; therefore, the iterator only iterates on the Block and Parcel polygon feature classes.

The tool has two outputs:

How to use Iterate Feature Classes

Iterate Files

To understand the use of Iterate Files in ModelBuilder, see the illustration below, where the Input Folder variable has a list of ASCII files to be converted to raster. The iteration has been restricted with a wildcard f* and the file extension .txt so that it will only iterate over files starting with letter F and of type text.

The tool has two outputs:

How to use Iterate Files

Iterate Rasters

To understand the use of Iterate Rasters in ModelBuilder, see the illustration below, where the model resamples grid datasets and extracts a subset for further analysis.

The Input Rasters variable is a folder containing grids, images, and TIFFs. In this case, iteration has been restricted with a wildcard A* and raster type of GRID so that it only iterates over rasters starting with the letter A and only on grids.

The tool has two outputs:

How to use Iterate Rasters

Iterate Tables

To understand the use of Iterate Tables in ModelBuilder, see the illustration below, where the model transposes land-cover tables of each state with a land-cover type and summarizes the statistics—like sum of area—for each class of land cover.

The input workspace variable is a folder containing the tables. The iteration has been restricted with a wildcard L* and a table type of DBASE so that it only iterates over dBASE tables starting with the letter L.

The tool has two outputs:

How to use Iterate Tables

Iterate Workspaces

To understand the use of Iterate Workspaces in ModelBuilder, see the illustration below, where the model creates a new mosaic using rasters stored in a geodatabase named Arizona, which is stored inside a folder.

The iteration has been restricted with the wildcard Ar* and workspace type of FILEGDB so that it only iterates over file geodatabases with names starting with the letters Ar.

The tool has two outputs:

How to use Iterate Workspace
6/18/2012