Iterators

Iteration, often referred to as looping or batch processing, means to repeat a process over and over with some degree of automation. Iteration is important because automating repetitive tasks reduces the time and effort required to perform the tasks. With iteration in ModelBuilder, a process can be run over and over using different settings or data in each iteration. ModelBuilder also provides flexibility in iteration, as an entire model or a single tool or process can be run repeatedly.

  • Video length: 2:02
  • This video was created with ArcGIS Pro 3.0.
Note:
  • Only one iterator can be used per model. The options to add another iterator will be disabled if one iterator exists in the model.
  • If an iterator is added to a model, all tools in the model iterate for each value in the iterator. If you do not want to run each tool in the model for each iterated value, create a submodel/model within a model/nested model that contains only the iterator and add it as a model tool into the main model.
  • To give a unique name to the output of any tool connected to an iterator, use inline variable substitution.

There are a number of iterators in ModelBuilder that you can use for iterating over different values, datasets, and workspaces.

IteratorDescription

For

Iterates over a starting and ending value by a given value.

Iterate Datasets

Iterates over different types of datasets in a workspace.

Iterate Feature Classes

Iterates over feature classes in a workspace or feature dataset.

Iterate Feature Selection

Iterates over features in a feature class.

Iterate Field Values

Iterates each value in a field.

Iterate Fields

Iterates fields in a table.

Iterate Files

Iterates over files in a folder.

Iterate Layers

Iterates layers in a map.

Iterate Multivalue

Iterates over a list of values.

Iterate Rasters

Iterates over rasters in a workspace.

Iterate Row Selection

Iterates over rows in a table.

Iterate Tables

Iterates over tables in a workspace.

Iterate Time

Iterates over time in a date field.

Iterate Workspaces

Iterates over workspaces in a folder.

While

Iterates until a condition becomes true or until a condition comes false.

Add and use an iterator

To add an iterator to your model, click ModelBuilder > Insert > Iterator and choose from the list of iterators.

Double-click the iterator element to view and change its settings. A commonly used iterator, Iterate Feature Classes, is shown and explained below.

Iterate Feature Classes

ElementDescription
Workspace

Input workspace (such as a geodatabase) or a feature dataset.

Wildcard

Combination of * and characters that help to limit the results. For example, A* means that only feature classes starting with A are included. This is optional.

Feature Type

A feature type filter that helps limit the results. The most common are Point, Line, and Polygon. This is optional.

Recursive

Determines whether the iterator will go into subfolders in the workspace. This is optional.

Output Feature Class

Output variable that contains the path of the feature class. This variable can be used as input to all geoprocessing tools that accept feature layers or feature classes.

Name

Output variable that contains the name of the feature class. This is a string.

The Iterate Feature Classes tool requires an Input Workspace value (the variable named Workspace in the graphic above) where all the feature classes to iterate through are stored. Three additional settings, Wildcard, Feature Type, and Recursive, are used to restrict which feature classes in the workspace are iterated and control the iteration in subfolders in the workspace.

The Iterate Feature Classes tool has two output variables: a feature class and the name of the feature class. The feature class variable can be connected to the next tool for processing, and the Name variable can be used for inline variable substitution.


In this topic
  1. Add and use an iterator