ArcGis Model Builder: Expanding a Model to an Input Dataset

There are always two psychological barriers to overcome with Model
Builder:

  • the first one is deciding to,
    actually, use it and move from the interactive, natural working mode to ArcMap,
    i.e. to a working mode where all the workflow is performed virtually, before
    actually launching it
  • the second, when you are,
    already, comfortable with the tool and start creating increasingly complex
    models, but always based on an input layer producing an output layer. And then, you think it would be nice to be able to
    apply the model automatically to a whole batch of input data, and somehow you
    find out that it is necessary to use “iterators”.

If you are facing the first barrier, keep this article in a safe place
since it will serve you one day, but nor right now. On the other side if you
are facing the second barrier, we will try to overcome it together.
There are two main types of iterators; those looking for multiple layers of
data and those looking for multiple entities in a single data layer.

In this article we will only discuss the first type of iterators, those
that will look for several layers of input data. In a separate article we will discuss
the other iterators.

We’ll follow the examples with ArcGis Pro

but
it’s the same for ArcMap.

Let’s
consider a simple model:

It can get really complicated but, at last, you will get a (sometimes various)
blue ellipse representing the input data, and one (or more) green ellipse
representing the output data.

When we want to use the iterators, we have to focus on these two
ellipses and forget about the rest of the model.

First step: For the model to work on different batches of
input data, it will be necessary to choose the type of iterator.

Second step: we will set it up and format it to do exactly what
we want.

Third step: we must analyze what type of output we want, and
here there are two possibilities:

  • we want a single output, a single
    file that gathers the results of all input files
  • we want a different output for
    each input file

When the previous has been done, the problem is virtually solved. Before
seeing the different iterators, it is important to know how to link the first
and the last step.

Most iterators have a structure of this type:   

The iterator produces two outputs:

  • the first is a data layer that
    will fit into the model
  • the second is a
    “textual” variable, containing the name of the input layer.

It is this variable that we will use to customize the model output layer,
usually by adding this name in the output layer. As each input layer has a
different name, the corresponding output layer will also have a different name.

Last but not least: most iterators are limited in scope. They will look
for a data layer type in a restricted space that can be either a workspace or a
geodatabase (feature dataset). Before complicating the task with layers
distributed everywhere on your disks, please consider, if possible, to gather
them in a single directory or geodatabase.

How to decide which is the right iterator?

To answer this question, it is, usually, just enough to set the problem
in plain English: for example “I want to apply my model to all the
images of a directory”
or “I want to apply the model to all
polygon layers of my geodatabase “
, etc …

Let’s look at the most frequent cases and the corresponding iterators:

Expression
of the iterator
Iterator
to use
datasets
of a given type (raster, feature class, tile, …) in a directory or
geodatabase
Iterate
Datasets (Datasets)
the
feature classes of a given type (polygons, lines, points …) shapes of a
directory or feature classes of a geodatabase
Iterate
feature classes
the
files of a directory
Iterate
Files (files)
rasters
of a certain format from a directory or a geodatabase
Iterate
rasters (rasters)
tables
in a directory or geodatabase
Iterate
tables
the
sub-workspaces of a workspace (the geodatabases of a directory, …)
Iterate
Workspaces (workspaces)

Iterate Datasets

You define the directory or geodatabase containing the datasets
You can use a mask name of (with *)
You define the type of dataset to be processed by selecting it from the list
You check the Recurrent box if you want to take into account also the
subdirectories in the directory

The DATASET output must be connected to the first tool of the model.
The output Name will be used for the output data (see below) Iterate feature classes

You define the directory or geodatabase containing the feature classes
You can use a mask name of (with *)
You define the type of feature classes to process by selecting it from the list

You check the Recurrent box if you want to take into account also the
subdirectories in the directory

The Feature Class output must be connected to the first tool in the
model.
The output Name will be used for the output data (see below) Iterate Files

You define the directory containing the files
You can use a mask name of (with *)
You define the extension to take into account (TXT, ASC, …)
You check the Recurrent box if you want to take into account also the
subdirectories in the directory

The FILE output must be connected to the first tool of the model.
The output Name will be used for the output data (see below) Iterate Rasters

You define the directory or geodatabase containing the feature classes
You can use a mask name of (with *)
You define the type of raster to be processed by selecting it from the list
You check the Recurrent box if you want to take into account also the
subdirectories in the directory

The RASTER output must be connected to the first tool of the model.
The output Name will be used for the output data (see below) Iterate tables

You define the directory or geodatabase containing the tables
You can use a mask name of (with *)
You define the type of table to be processed by selecting it from the list
You check the Recurrent box if you want to take into account also the
subdirectories in the directory

The TABLE output must be connected to the first tool of the model.
The output Name will be used for the output data (see below) Iterate Workspaces

You define the directory containing the geodatabases or directories.
You can use a mask name of (with *)
You define the type of workspace to process by selecting it from the list
You check the Recurrent box if you want to take into account also the
subdirectories in the directory

The output WORKSPACE must be connected to the first tool of the model.
The output Name will be used for the output data (see below)

Name of the resulting layer

By opening the last tool of a model, you will always find the “Output”
field, where you will define the place and the name of the resulting layer. For
example:

C: \ Users \ admin \ Documents \ ArcGIS \ Projects
\ MyProject10 \ HYDROGRAPHIE_SURFACIQUE.shp

So that, at each iteration, the resulting layer has a different name (if
not each consecutive output overwrites the previous one) you have to add a
variable element in the name.

This element will be the iterator output NAME. To insert NAME into the layer
output name, simply insert NAME between % in the desired place of the string
name, for example:

C: \ Users \ admin \ Documents \ ArcGIS \ Projects
\ MyProject10 \ HYDROGRAPHIE_SURFACIQUE_% NAME% .shp

At each iteration, % NAME% will be substituted by the name of the input
layer.

If you have held so far, you deserve to read the next article where we
will discuss other types of iterators that play a role in a layer features.

Si cet article vous a intéressé et que vous pensez qu'il pourrait bénéficier à d'autres personnes, n'hésitez pas à le partager sur vos réseaux sociaux en utilisant les boutons ci-dessous. Votre partage est apprécié !

Leave a Reply

Your email address will not be published. Required fields are marked *