Iterators enable batch processing and help repeat a process or set of processes on a set of inputs.
For
In the image below, 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 inline variable substitution.
While
In the image below, the model selects all the block groups that share a boundary with an area of interest, calculates its total population, and makes a layer in which the population is less than a threshold value for example, a business trying to reach a set population value for coupon offers surrounding a particular block group. The Get Count tool checks to see if there are any selections that match the criteria set in the Make Table View tool. While ensures that the model runs until the row count is not zero.
Iterate Feature Selection
In the image below, 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:
- Selected feature (connected as input to the Zonal Statistics As Table tool).
- The Value variable, which contains the name of the feature (based on the grouping field) used as an inline variable in the output name of the Output Table variable.
Iterate Row Selection
In the image below, 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:
- The Row Selection variable containing the selected rows for a unique crime period. These rows are input to the Directional Distribution (Standard Deviational Ellipse) tool.
- The Value variable, which contains the value of the grouping field (Morning, Afternoon, Evening, or Night). This value is used as an inline variable in the output name of the Output Standard Deviational Ellipse variable.
Iterate Fields
In the image below, the model uses the Calculate Field tool to convert the null values in multiple fields to zeros.
The Incidents feature layer variable has unique fields with count for number of incidents by date. Some of the fields have missing values stored as nulls. In this case, the Iterate Fields tool is used to filter the days based on a wild card and a subset of filtered field list. Each field is then passed to the expression of the Select Layer By Attribute tool and the selected records are then passed to the Calculate Field tool.
The tool has two outputs:
- Value variable connected as the input field name to the Select Layer By Attribute tool. The Count variable keeps a total count of number of fields to iterate over.
Iterate Field Values
In the image below, the model uses the Cluster And Outlier Analysis tool 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 variable containing 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 inline variable substitution.
Iterate Multivalue
In the image below, 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.
Iterate Datasets
In the image below, 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:
- Dataset (Land and Transportation).
- Name, which is used as the inline variable %Name% in the output of the Copy tool.
Iterate Feature Classes
In the image below, the model finds the population density for the Blocks and Parcels 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 Blocks and Parcels polygon feature classes.
The tool has two outputs:
- Output Feature Class variable (Blocks and Parcels) connected to the Add Field tool as input.
- Name variable (Blocks and Parcels, in this example), which could be used as the inline variable %Name% in other tools.
Iterate Files
In the image below, the Input Folder variable has a list of text 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 the letter f or F and of type text.
The tool has two outputs:
- The File variable (focaldem1.txt, focaldem2.txt, or focaldem3.txt) connected as input to the ASCII To Raster tool.
- The Name variable containing the name of the text file (focaldem1, focaldem2, or focaldem3). This Name variable is used in the output of the next tool as an inline variable %Name%.
Iterate Rasters
In the image below, 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 or A and only on grids.
The tool has two outputs:
- Output Raster variable (Aland, Aparcel, and Aroad) connected as input to the Resample tool.
- Name variable, which is used in the output name of the Resample and Extract Subset tools as the inline variable %Name%.
Iterate Tables
In the image below, the model transposes land-cover tables of each state with a land-cover type and summarizes the statistics—such as sum of the 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 or L.
The tool has two outputs:
- Output Table variable (Landcover_Arizona, Landcover_California, and Landcover_Nevada) connected to the Pivot Table tool as input.
- Name variable, which is used as an inline variable %Name% in the output names of the Pivot Table and Summary Statistics tools.
Iterate Workspaces
In the image below, the model creates a 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 file geodatabase so that it only iterates over file geodatabases with names starting with the letters Ar.
The tool has two outputs:
- Output Workspace variable, containing Arizona.gdb, is connected to the Workspace To Raster Dataset tool as input.
- Name variable, which can be used as an inline variable %Name% in the output name of subsequent tools.