Model Builderfor Pro
Model Builderfor Pro
Workbook
v3.1
ArcGIS Pro: Working with ModelBuilder
Copyright
Copyright © 2010-2021 Environmental Systems Research Institute, Inc. and ESRI (UK) Ltd
All rights reserved. Printed in Aylesbury, Bucks, England.
The information contained in this document is subject to change without notice and is the exclusive property of ESRI (UK)
Ltd. and Environmental Systems Research Institute, Inc., and any respective copyright owners. This work is protected under
United Kingdom and United States copyright law and other international copyright treaties and conventions and except with
the prior written consent of ESRI (UK) Ltd, shall be used solely for the purpose of undergoing training provided by or with
the express written permission of ESRI (UK) Ltd. To the extent permitted by law, no part of this work may be reproduced or
transmitted in any form or by any means, electronic or mechanical, including but not limited to photocopying and recording,
or by any information storage or retrieval system, except as expressly permitted in writing by ESRI (UK) Ltd. If any lawful
copies are made, all such copies, whether in whole or in part, shall include the appropriate ESRI (UK) Ltd and
Environmental Systems Research Institute, Inc. copyright notice. All requests should be sent to Attention: Contracts
Manager, ESRI (UK) Ltd., Millennium House, 65 Walton Street, Aylesbury, Bucks HP21 7QG, England.
@esri.com, 3D Analyst, ADF, AML, ARC/INFO, ArcAtlas, ArcCAD, ArcCatalog, ArcCOGO, ArcData, ArcDoc, ArcEdit,
ArcEditor, ArcEurope, ArcExplorer, ArcExpress, ArcFM, ArcGIS, ArcGrid, ArcIMS, ArcInfo Librarian, ArcInfo,
ArcInfo—Professional GIS, ArcInfo—The World's GIS, ArcLogistics, ArcMap, ArcNetwork, ArcNews, ArcObjects,
ArcOpen, ArcPad, ArcPlot, ArcPress, ArcQuest, ArcReader, ArcScan, ArcScene, ArcSchool, ArcSDE, ArcSdl, ArcStorm,
ArcSurvey, ArcTIN, ArcToolbox, ArcTools, ArcUSA, ArcUser, ArcView, ArcVoyager, ArcWatch, ArcWeb, ArcWorld,
Atlas GIS, AtlasWare, Avenue, BusinessMAP, Database Integrator, DBI Kit, ESRI, ESRI—Team GIS, ESRI—The GIS
People, FormEdit, Geographic Design System, Geography Matters, Geography Network, GIS by ESRI, GIS Day, GIS for
Everyone, GISData Server, InsiteMAP, MapBeans, MapCafé, MapObjects, ModelBuilder, MOLE, NetEngine, PC
ARC/INFO, PC ARCPLOT, PC ARCSHELL, PC DATA CONVERSION, PC STARTER KIT, PC TABLES, PC
ARCEDIT, PC NETWORK, PC OVERLAY, Rent-a-Tech, RouteMAP, SDE, SML, Spatial Database Engine, StreetEditor,
StreetMap, TABLES, the ARC/INFO logo, the ArcAtlas logo, the ArcCAD logo, the ArcCAD WorkBench logo, the
ArcCOGO logo, the ArcData logo, the ArcData Online logo, the ArcEdit logo, the ArcEurope logo, the ArcExplorer logo,
the ArcExpress logo, the ArcFM logo, the ArcFM Viewer logo, the ArcGIS logo, the ArcGrid logo, the ArcIMS logo, the
ArcInfo logo, the ArcLogistics Route logo, the ArcNetwork logo, the ArcPad logo, the ArcPlot logo, the ArcPress for
ArcView logo, the ArcPress logo, the ArcScan logo, the ArcScene logo, the ArcSDE CAD Client logo, the ArcSDE logo,
the ArcStorm logo, the ArcTIN logo, the ArcTools logo, the ArcUSA logo, the ArcView 3D Analyst logo, the ArcView
Business Analyst logo, the ArcView Data Publisher logo, the ArcView GIS logo, the ArcView Image Analysis logo, the
ArcView Internet Map Server logo, the ArcView logo, the ArcView Network Analyst logo, the ArcView Spatial Analyst
logo, the ArcView StreetMap 2000 logo, the ArcView StreetMap logo, the ArcView Tracking Analyst logo, the ArcWorld
logo, the Atlas GIS logo, the Avenue logo, the BusinessMAP logo, the Data Automation Kit logo, the Digital Chart of the
World logo, the ESRI Data logo, the ESRI globe logo, the ESRI Press logo, the Geography Network logo, the MapCafé
logo, the MapObjects Internet Map Server logo, the MapObjects logo, the MOLE logo, the NetEngine logo, the PC
ARC/INFO logo, the Production Line Tool Set logo, the RouteMAP IMS logo, the RouteMAP logo, the SDE logo, The
World's Leading Desktop GIS, Water Writes, www.esri.com, www.geographynetwork.com, www.gisday.com, and Your
Personal Geographic Information System are trademarks, registered trademarks, or service marks of ESRI in the United
States, the European Community, or certain other jurisdictions.
Other companies and products mentioned in this document may be trademarks or registered trademarks of their respective
trademark owners.
INFO and PC-INFO are trademarks of Doric Computer Systems International Ltd.
ArcView GIS uses Neuron Data’s Open Interface
Contains Ordnance Survey data © Crown copyright and database right 2021
Table of Contents
The aim of this course is to teach you how to use ModelBuilder within ArcGIS Pro.
ModelBuilder allows you to create models which let you to automate, visualise, and
document your spatial analysis and data management processes.
If delivery is face-to-face:
• Internet access
• Please turn off mobiles or set to silent
• Using Student ID badges and passes
• Refreshment, toilet and smoking facilities
• Emergency procedures
• Morning, lunch, and afternoon breaks
The capabilities of the Platform can be grouped into the following categories:
Mapping & Visualization: Create, share, and use interactive high-quality 2D maps and 3D
scenes.
Spatial Analytics: Perform spatial analysis on your (or other organisation's) data; from
visualizing and measuring patterns and relationships, to complex feature overlay and
proximity analysis, and predictive modelling.
3D GIS: Convert data into 3D GIS to analyse and solve real-world problems.
Near Real-time GIS: Monitor and analyse live data feeds from sensors to make timely
decisions and to obtain a common operational picture.
Imagery & Remote Sensing: Collect, process, analyse, manage, and share imagery from
satellite, aerial, drone, and full motion video.
Data Collection & Management: Collect, integrate, geo-enable, store, access, and share
your data efficiently and securely.
Introduction
You will have come across ModelBuilder in one of the previous courses, namely “An
Introduction to ArcGIS Pro for GIS Newcomers” and “Introduction to ArcGIS Pro for GIS
Professionals”. This is just a quick overview of things which you should already be fairly
familiar with.
Learning objectives
After completing this lesson, you will be able to:
Geoprocessing models automate, visualise, and document your spatial analysis and data
management processes. You create and modify geoprocessing models in ModelBuilder,
where a model is represented as a diagram that chains together sequences of processes and
geoprocessing tools, using the output of one process as the input to another process.
ModelBuilder is a visual programming language for building geoprocessing workflows; it is
intuitive, easy-to-learn and use, and can help you be more productive from the first day you
use it.
• Build a model by adding geoprocessing tools, map layers, datasets, and other
variables, and connecting them into a process.
• Iteratively process every feature class, raster, file, table, etc. in a workspace.
• Visualise your workflow sequence as an easy-to-understand diagram.
• Run tools step-by-step, up to a selected step, or run the entire model.
• Make your model into a geoprocessing tool that can be shared with others or can be
used in Python scripting and other models.
Let’s create a simple mode which performs a simple operation of creating a new feature
class and then adding a new field to it. You will then answer 6 questions about the
ModelBuilder interface.
b. Use a Catalog template and for Name type in MyModel and for Location browse to:
C:\EsriTraining\MBOP\MyFirstModel
A default geodatabase and toolbox based on the name of the ArcGIS Pro project is created.
d. Create a new model in the Catalog > Toolboxes > MyModel toolbox.
f. Display the Geoprocessing pane (Analysis tab > Geoprocessing group > Tools)
g. Search for the Create Feature Class tool and drag it on to the model canvas.
h. Double click the Create Feature Class tool in the model to display the Properties
dialog box.
The parent geodatabase has already been selected and is based upon the project’s default
geodatabase.
As the mandatory parameters have been filled in the model is coloured in:
j. Search for the Add Field tool and drag it onto the model canvas.
k. Connect the MyFeatureClass output to the Add Field tool and choose Input Table.
l. Double click the Add Field tool and fill in the following:
As you have seen the ModelBuilder tab is displayed when a new model is created or
activated. As with all ribbons, the interface is divided up into a series of groups which contain
the various UI controls (buttons, drop down boxes, tools etc).
Using the model you have created, answer the following questions by hovering over the
relevant UI controls on the ModelBuilder ribbon:
Question 1: What is the difference between Auto Layout and Fit To Window?
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
End of exercise
Introduction
In the introductory chapter you created a model which created a new feature class and
added a new attribute field into an existing geodatabase. You chose many default options
and as such your model was quite static.
In this section you will learn how to make your model more dynamic by working with model
parameters. You will also investigate the ModelBuilder user interface and the role the
geoprocessing environment settings play in running your model.
Learning objectives
After completing this lesson, you will be able to perform the following tasks:
• Application
• Model
• Tool
• Model process
These levels form a hierarchy in which the application level is highest.
In this hierarchy, environment settings are passed down to the next level. At each level, you
can override the inherited environment settings with a manual setting.
If you run the model from the ModelBuilder window, the application environment settings
are passed down.
If you run the model using its tool dialog box (i.e. from within a toolbox), then the tool
environment settings are passed down.
Application-level
Application-level settings are system wide defaults and are saved within the project. They
are applied to any tool when it is executed.
Application level settings can be accessed via the Analysis tab > Environments button.
Tool settings
Tool settings are applied to a single run of a tool. They temporarily override application-level
settings and are not saved anywhere.
Model settings
These are specified within a model's tool dialog box. Model settings override tool and
application-level settings depending upon where the model is run.
Model process-level
These settings are specified at the model process-level (a process is a tool with its inputs
and outputs) and saved with the model. They override all other settings.
The different types of model elements are displayed in the diagram below:
Geoprocessing Tools
Geoprocessing tools perform various operations on geographic and tabular data – there are
over 1000 tools in ArcGIS Pro. As with tools run from the toolbox, a geoprocessing tool
which is part of a model must have mandatory arguments assigned either through a
variable, parameter variable or from within the dialog box of the tool element.
Existing custom model and script tools can be added as well as so-called Model-Only tools
which are grouped as Iterators, Utilities and Logical tools. You will investigate these more in
the course.
Input data can be pathways (workspaces), and datasets such as feature classes, feature
layers and rasters.
Derived Data can be thought of as output data or data created by a tool in the model.
Derived Data can either be New Derived Data – this is a new dataset written to disk – or In /
Out Derived Data which is created when a tool alters its input data; a good example being
the result of the Add Field geoprocessing tool.
Value variables store standard data types such as numbers, strings and booleans and can
either be input values or derived values.
Input Values can be a range of things such as numbers, strings, booleans, spatial references,
linear units and extents.
Derived Values relates to data created by tools and are usually used as the inputs to other
geoprocessing tools, such as the Calculate Value tool.
Precondition connectors control the order in which a series of processes are run. For
example, a process can be made to run only after a previous process has run.
Feedback connectors allow the output of one process to be the input of a previous process.
Groups
Groups contain elements and they are no more than a visual grouping. They can be
expanded and collapsed to show or hide their contents.
You can select elements and use the Group button to group them together. Elements inside
of the group can be automatically re-arranged by right clicking the group and choosing Auto
Layout.
Adding Tools
A tool is added to the canvas in one of three ways:
Once the required tool parameters are specified, the tool variable changes to a yellow
colour, indicating the process is ready to run.
The tool parameters can be populated by either opening the tool dialog and filling in the
parameters or by adding or filling in existing variables associated with a tool.
• Data variables can be added by populating the tool dialog directly. This will create an
input value which references the source data.
• Data variables can be dragged and dropped from the Catalog pane onto the canvas.
• The Insert group contains the Variable button which is used to add variables to the
canvas.
• Variables can be added through a right click on the model canvas, which can be
optionally connected to a tool.
• Right clicking the tool allows for the creation of a variable from the tool’s
parameters.
Once the variable has been created it usually needs to be connected to the tool.
All you need to do is click and hold the left mouse button while you move the cursor to the
tool to make a connection. When the cursor is over the tool decide which tool parameter
the variable should be connected to.
In the example on the next page the Buffer tool has been added. It requires three
mandatory arguments; Input feature class, output feature class and linear unit (buffer
distance or field.
The linear unit variable has been added and is in the process of being connected to the
Buffer tool. When the cursor moves over the tool a list of possible parameters displays; the
one relevant (and mandatory) parameter and a list of optional parameters. The choice to be
made should be the Distance (value or field) parameter.
Validation is the process of checking that the model is in a ready to run state.
Validation occurs automatically when the data and tools are added and connected.
As changes are made to the model then it is necessary to re-validate the model; for example
the data changes or tools are modified (for example, pathways are changed), moved,
renamed or deleted. You can manually validate the model by choosing ModelBuilder tab >
Run group > Validate.
The model will need to be validated if all processes have been run inside of ModelBuilder to
set the model back to its ready to run state.
The model can be run inside of ModelBuilder, predominantly for testing. The model, or a
portion of a model, can be run.
Run a single process: Running a single process allows you to run an individual tool in the
model. To achieve this just select a tool, right-click, and select Run.
Run the entire model: When you click ModelBuilder tab > Run group > Run on the ribbon,
all ready to run tools execute in sequence. If some tools have already been run, they are not
re-executed; the model will begin executing from the first tool that has not yet been run.
Derived datasets will be created and stored in the specified workspace for the tool which
allows you to inspect them. This is handy in the testing process.
A static model
If the model is in its ready to run state then the required data names and locations are
hardcoded: the model is said to be static. When a model is opened in the Geoprocessing
pane, the tool dialog box will display no parameters.
When the model is run it uses its internal hard-coded values and any output datasets will
not be added to the active map.
When the model tool dialog is opened via the Geoprocessing pane then the parameter is
displayed and ready to receive user input.
NOTE: Any changes you make to the model must be saved within the model
using the Save button on the ModelBuilder ribbon.
As you can see the name of the variable is used as the model tool parameter label. You can
rename a model parameter by renaming the model variable in ModelBuilder. Right-click the
variable, select Rename, and enter the new name.
The renamed parameter is displayed on the model tool dialog along with its default value.
Or by right clicking the model in the Catalog pane and choose Properties.
General
General properties determine the internal (Name) and visible (Label) names of the model.
A password can be set which provides a degree of protection against those who might wish
to alter your model.
The Label, Data Type and Direction are read only – the other parameter properties can be
modified as long as they are not required by the associated geoprocessing tool.
Tool parameters have a Type which can be required or optional. The designation for optional
or required parameters happens automatically based on how the parameter is used in the
model. The model parameter that ModelBuilder designates as optional can be changed to
required for the model tool, but a required tool parameter cannot be set to optional.
Parameter filters are used to limit or restrict the input values or data that can be specified
for a model tool parameter. For example, a Value List filter requires that only values from a
list can be specified for the parameter. The model cannot be executed until a valid value is
entered.
Value list A list of valid keywords. You can set a value list filter for
string and numeric model parameters.
Range: Specify a minimum and maximum numeric value. The
range is inclusive, meaning both the minimum and
maximum are valid choices.
Feature Type A list of allowable feature shape types, such as point,
multipoint, polyline, polygon, and multipatch.
File A list of valid file extensions such as txt or gpx.
Field A list of allowable field types, including short, long, single,
double, test, date, OID, geometry, BLOB, raster, GUID,
global ID, and XML.
Workspace A list of valid workspaces, including file system, local
geodatabase, and enterprise geodatabase.
Dependency allows for one parameter to be dependent upon another. An example of this
would be to have a field info parameter be dependent upon an input feature class or table
so when the dataset is updated the field info object is updated with a new list of attribute
fields.
The Symbology of an output parameter can be used to specify how the model outputs
should be symbolised when added to a map. The Symbology option achieves this by
specifying a pathway to a layer (.lyrx) file.
The order of the parameters on the model tool dialog can be controlled by dragging and
dropping the parameters to the desired order in the Parameters page.
In this exercise you will work with an existing model to change the way it behaves.
You have been given a model which is static; the input variables are hardcoded. This means
that every time the model is run the same output is created. You have been asked to amend
the model to allow the end user to make choices as to the inputs which the model can
receive. You have also been asked to annotate the model as you may want to use the model
as a training aid for future models.
C:\EsriTraining\MBOP\ModelBuilderBasics\BufferAndClip\BufferAndClip.aprx
The project opens to display a map displaying central Bristol. It contains two feature layers;
Major Bristol Roads and Planning Applications, as well as the GB Light Grey basemap.
A folder to C:\EsriTraining\MBOP has also been created which provides access to the
contents of that folder.
Question 1: What is the current value for ‘Allow geoprocessing tools to overwrite existing
datasets’?
___________________________________________________________________________
___________________________________________________________________________
The checkbox is ticked which means that any existing datasets can be overwritten by
geoprocessing processes such as running a model or a geoprocessing tool.
Inside is a toolbox called BufferandClip and inside that is a model called Buffer and Clip.
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Question 3: What is the distance to which the Bristol roads are being buffered to?
___________________________________________________________________________
___________________________________________________________________________
Question 4: On the Clip tool what is the name of the Input Features and what do they
represent?
___________________________________________________________________________
Question 5: What is the name of the clipped output dataset and which location is it written
to?
___________________________________________________________________________
___________________________________________________________________________
Now that you understand what the model does you are now ready to investigate the
different ways in which the model can be run.
First of all you will make a selection in the Major Roads layer as you want to use just those
selected features as input into your model.
b. Use the Select by Attributes tool to construct a query which selects those Major
Bristol Roads called Park Street.
HINT: Investigate the attribute table to identify the field name containing the names of the
roads.
Once the tool has run you should have 9 features selected.
This makes sure that all data references are available and sets your model state to “ready to
run”.
As the model runs the geoprocessing dialog is displayed which contains the progress
messages.
Notice the location where the output dataset is written to. This is the same location which
you noted as the answer to Question 5
g. In the Catalog tab locate the Databases icon and expand it.
The BufferAndClip geodatabase is the default geodatabase for the project where the output
of the model is written to.
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
i. Add both feature classes into the map and zoom to the extent of the buffer layer.
You can see that there are multiple buffers as there are multiple street selected.
When running a model inside ModelBuilder all intermediate datasets are created and kept in
the workspace. This is useful for testing and validating your model logic.
k. Press the OK button to confirm that the feature classes are to be deleted.
l. Expand Toolboxes > BufferAndClip to display the Buffer and Clip model.
Notice that the dialog has no opportunity to enter any information or data into it. This is
because no variables have been exposed to allow user input.
Notice again that no datasets are added to the map. You will fix this in the next step.
___________________________________________________________________________
___________________________________________________________________________
As you can see only the output feature class is stored in the geodatabase. The intermediate
buffer dataset has not been created this time.
When you run a model from the toolbox only the output dataset is created – no intermediate
datasets are written to the workspace at all. This is an important distinction between the
two environments – run the model from ModelBuilder when you are testing the model.
The key to making a model dynamic – that is to allow user input – is to make the variables
model parameters.
Let’s make the model add the output to the map automatically.
If you make any change to the model and you want the toolbox to pick up the changes then
you must save the model.
NOTE: You MUST save your changes in the model if you want to see the
effect of those changes when you run the model in the toolbox.
Notice this time that the ClippedPlanningApps parameter is displayed on the dialog:
Notice the yellow warning triangle ? This is displayed because there is already a dataset of
that name in the output geodatabase. You are allowed to overwrite it because the ‘Allow
geoprocessing tools to overwrite existing datasets’ checkbox is ticked. If it wasn’t ticked then
there would be an error icon displayed.
Once processing has finished the ClippedPlanningApps dataset is automatically added to the
map:
h. In the box type in Output Dataset Name and save the model.
i. To confirm this, double click the Buffer and Clip tool in the toolbox.
You will do one more thing in this step and that is allow the user to choose the buffer
distance and units via the tool dialog.
j. In ModelBuilder double click the Buffer tool to display the tool dialog.
Notice that the Distance [value or field] parameter is filled in already. This is a mandatory
parameter which the tool needs for it to run.
k. Remove the value 75 and press the OK button on the tool dialog.
When you do this then many of elements turn grey. This indicates that the model is no longer
in a fit state to run.
l. Right click the Buffer tool and choose Create Variable > From Parameter > Distance
[value or field].
Notice the changes you have made are now reflected on the dialog:
That is the end of the mandatory part of the exercise. If you wish you can go to the optional
step on the next page or you can go and get a cup of tea or have a smoke.
a. On the ModelBuilder ribbon click the Label button on the Insert group.
HINT: You will need to click the Select tool in order to move the Label
element.
Geoprocessing model which will take a selection of the Bristol Roads layer and perform a
proximity analysis to identify the planning applications within a specified distance
HINT: If you need to add a newline to your title you can do by choosing <shift> + <Return> at
the same time.
d. Set the size of the text to be 14 using the tools in the Text group on the ModelBuilder
ribbon and change the text colour to red
g. Set the size to 12 and resize the text box to display the text.
When a label is created via the element then when the element is moved the label moves in
conjunction with it.
This display the properties of the variable parameters in the model. These are the
parameters which are displayed on the dialog.
You will do one more thing while the dialog box is open. You will associate a layer file to the
Output Dataset parameter. This means that anytime the model runs the output will always
have a set of standard symbols.
k. In the Output Dataset parameter scroll along until the Symbology field is located.
l. Click inside this grid square (as indicated in the above picture).
n. Press the OK button on the properties dialog, validate and save your model.
Let’s see how the changes affect the dialog and the output symbology.
The output dataset has the symbology properties of the layer file!
End of exercise
Introduction
Batch processing is the process of repeating a workflow based upon some sort of condition,
such as running a model exactly three times, or apply a workflow to all feature classes in a
particular geodatabase.
The key to batch processing in ModelBuilder is using the iteration tools. Iteration is very
important because automating repetitive tasks reduces the time and effort required to
perform the tasks. With iteration in ModelBuilder, a process can be executed over and over
using different settings or data in each iteration.
In this section you will investigate and understand the different types of iterator and how to
use them.
Browse to the following location either in the installed ArcGIS Pro help or online at
https://pro.arcgis.com/en/pro-app/latest/help/main/welcome-to-the-arcgis-pro-app-
help.htm Analysis and Geoprocessing > Geoprocessing > ModelBuilder > Advanced
Techniques > Iterators
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Question 4: What iterator would you choose if you wanted to run a workflow a specific
number of times?
___________________________________________________________________________
___________________________________________________________________________
Question 5: How would you iterate over each row or feature in a table or feature class?
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Each iterator has many arguments such as a wildcard, or input workspace. Many iterators
produce two outputs such as Name and the output object which the iterator is processing.
Iterate Files processes all the files in a directory. The required argument is a folder, and
there are three optional arguments (wildcard, File type and recursive) and it produces two
outputs; Name and File.
• For
• While
For iterator
The For iterator uses a start number, an end number and an optional step number. In the
example below the For iterator is used to buffer the features in an input feature class based
upon the current value. The first buffer distance (From Value) is 500 units, the next one is a
distance incremented by 500 units (i.e. 1000 units, and so on until the To Value value has
been processed.
While iterator
A While iterator will process a model’s workflow while a condition is Boolean true. An
example of this might be to continue processing a model to create a service area while the
population count in the service area is less than 25,000.
The While iterator allows for the checking of a condition downstream of the workflow.
There are two iterators which will process selected records in datasets:
Selected Features refers to the feature layer that is produced while Value refers to attribute
information based upon the fields in the Group By Fields argument.
In the example below the Input Features are hurricane tracks, grouped by the NAME field. A
feature layer is made based upon each group of features and applied against a landuse
raster to work out statistics of land cover based upon the track of the hurricane.
The similarities between the two iterators can be seen via the diagram below:
Both tools provide the possibility of inline variable substitution being used later on in the
model.
Iterate Layers
In the image below, the Input Map variable shows a list of layers to be projected. The
iteration is restricted to only iterate over point feature layers in the map. The output of the
Iterate Layers tool is tested against a defined coordinate system using the If Coordinate
System Is tool. If the coordinate system of a layer does not match the defined coordinate
system, the value of the output False variable changes to true and the connected Project
tool runs to project the incoming layer to a specified coordinate system.
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 output of the tool is a variable named Value and contains the value of the field that is
being processed. This variable can be used in for inline variable substitution (%Value%).
The Data Type parameter specifies the data type of the output variable. The default data
type is string, but depending on how the output will be used in the model, different data
types may be specified. For example, if your field contains the path to a text file, you can set
the Data Type to Text File and use the output variable as input to a tool that accepts a text
file such as the Make XY Event Layer tool.
The nice thing about this tool is that the tool accepts input from different workspaces based
upon the choice of the user.
In the above example the Iterate Multivalue iterator has one output called Value which is a
string representing the feature class name that is currently being processed.
The recommended way to create a multivalue input is to create a stand alone variable by
clicking Insert > Variable.
In the Variable Data Type dialog box, choose the data type and check Multiple Values.
In the example above, the input table has precipitation data from 1981 to 2020 excluding
the dry days. The Iterate Time tool divides the input data into one-month temporal slices
using the Date field. From the selected rows for each month, the average precipitation and
the count of rainy days are calculated using the Summary Statistics tool. The Calculate Field
tool is used to add the formatted Start Time value of each iteration in the summarized table
using inline variable substitution. The summary table for each month is appended back to
generate a single table using the Append tool.
Inline variable substitution uses a pair of % signs either side of a variable name:
%
A_Variable_Name%
If a variable or parameter called inFC has a value of “ConsArea” then a pathway can be
constructed to take advantage of the in-line variable:
..\MyProject.gdb\bristbus_ConsArea
Current Workspace: This is used to specify the default location for geoprocessing tool inputs
and outputs when running a tool in ModelBuilder. The default location is the project’s
default geodatabase.
Scratch Workspace: Tools that honour the scratch workspace use the specified location as
the default location for output datasets. Its primary purpose is for use in ModelBuilder and
Python. It defaults to the project’s default geodatabase.
One thing to note –if the Scratch Workspace is set then this location will be used in a model
tool. If the Scratch Workspace is not set the then Current Workspace will be used.
The Scratch Folder and Scratch Geodatabase environment settings should be used by a
Python script or a model if the resource is going to be published as a geoprocessing service
as the workspace is guaranteed to exist.
As datasets are written to RAM it must be noted that larger datasets may impact on
processing performance as the machine may start to run low on memory.
As the dataset is not been written to a disk-based location it is significantly faster when used
for processing.
Data written to the memory workspace is temporary in nature and will be deleted once the
application closes or using the Delete GP tool. It is a good idea to use memory workspaces
when working with so-called intermediate datasets and as soon as possible, free up system
memory resources.
The model is contained inside of a toolbox (.atbx) file if it is stored in a folder. The .atbx file
and any associated data that the model might be dependent upon can be zipped up and
distributed.
Notice that a geoprocessing package can be shared via the History pane.
A geoprocessing package can also be created by clicking the Share tab > Package group >
Geoprocessing Package.
You can decide what properties and content the package will include via the Geoprocessing
Package pane.
The package can be saved to either disk as a gprx file or to your Portal (ArcGIS Online or
ArcGIS Enterprise).
Provide a name and, if saving the package to a file, the location for your new package on
disk.
Summary:Provide a brief description as to what the package does and what data or files are
associated with it.
Tags: Tags need to be included as it is through tags that your colleagues and interested
parties can find your geoprocessing package within your portal.
Use the Include Enterprise and UNC Path Data option if you want to extract data from an
enterprise geodatabase, or UNC path data into a file geodatabase. If this option is not
checked, map layers continue to reference enterprise geodatabase data and UNC path data.
If you're uploading your package to an online account, specify how it will be shared:
• My Content
• My Organisation
• Groups
• Everyone—This option makes your content public. Anyone can access and see it.
The Attachments tab allows you to include other content, such as detailed documentation,
reports, and graphs.
For the package to be created successfully it must be analysed to check for any errors or
issues. All errors must be resolved. If any issues are discovered, they appear on the
Messages tab. Right-click each message to get more information, read the help for the error
or warning, and access suggested fixes.
In this exercise you will perform some processing on a raster dataset to create a resampled
version of the raster dataset for viewing at different scales by using the For iterator.
a. Start ArcGIS Pro and create a new map-based project called SoCal and store it in the
following location:
C:\EsriTraining\MBOP\WorkingWithIterators
C:\EsriTraining\MBOP\WorkingWithIterators
Inside the ..\WorkingWithIterators folder is a Data folder which contains a file geodatabase
called Vineyard.
c. Expand the file geodatabase and add the Elevation dataset into the Map window.
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Name: IteratorTools
Alias: IteratorTools
The Alias is important as it allows for the unique identification of tools within the
geoprocessing framework, and it is part of the geoprocessing tool naming convention within
the Python window.
h. Create a new model by right clicking the IteratorTools toolbox > New > Model.
i. Display the model properties dialog box and fill in the dialog box with the following
information:
Name: ResampleRaster
Label: Resample Raster
When the model is saved the model in the toolbox is updated with the changes you just
made in the Tool Properties dialog box.
At the end of the step your model should look like the following:
a. In the Geoprocessing pane search for the Resample tool and drag it onto the canvas.
b. Repeat the process for the Contour tool. Choose the Spatial Analyst version of the
tool.
There is no difference between the Contour tool found in the Spatial Analyst
extension and the equivalent tool found in the 3D Analyst extension. This is
one of a number of surface-based tools which are common between both
extensions.
c. Double click the Resample tool and in the tool’s dialog box fill in the parameters as
follows:
The Resample tool process is coloured to indicate that the process is ready to run:
The output of the Resample tool is going to be used as the input dataset for the Contour tool.
e. Connect the ElevResample variable to the Contour tool and choose Input Raster as
the parameter.
Notice that once the ElevResample tool is connected to the Contour tool, the Contour tool is
not “ready to run”.
___________________________________________________________________________
___________________________________________________________________________
Question 4: What required parameter does the tool need to be populated with?
___________________________________________________________________________
Once the tool has been populated with the Contour interval parameter the Contour process
is then “ready to run”.
h. Once the model has run, add the finished contour dataset and the intermediate
resampled DEM to the map.
j. Zoom into the raster dataset and check that the ElevResample dataset has been
resampled and the resolution of the raster is 40 metres.
You can inspect the ElevSample properties to determine the resolution. You can
investigate visually if the raster has been resampled by highlighting the ElevResample
dataset in the Contents pane and then in the ribbon go to Raster Layer > Compare >
Swipe.
k. Remove the two output datasets from the Contents pane and delete them from the
project’s SoCal default geodatabase
You have created and tested your model. You are now ready to add the For iterator which
will allow you to process the model based on a number of resample cell sizes.
An Esri blog article discusses how to work out what these scales are based upon the raster
resolution:
https://www.esri.com/arcgis-blog/products/product/imagery/on-map-scale-and-raster-
resolution/
The current cell size is roughly 28 metres – let’s round it up to a more workable number of 30
metres.
A formula in the blog article is available which will calculate the scale at which the raster
dataset should be viewed at if the resolution is 30 metres:
Based upon the formula a scale of 1:60000 is the optimum scale to view this raster dataset.
b. In the Resample Raster model add the For iterator and move it above the existing
processes.
d. In the For dialog box type a value of 30 for From Value (this is the starting value); 90
for To Value (this is the end value) and 15 for By Value (this is the value which the
From Value will be incremented by for each iteration of the model).
___________________________________________________________________________
___________________________________________________________________________
In this model the Value variable relates to the output (resampling) cell size.
You will try and connect the For iterator’s Value variable to the Output Cell Size for the
Resample tool.
Notice that there is no Output Cell Size option. This means you can not connect the For
iterator directly to the Resample tool.
So how are you going to add the current iterated value into the Resample tool?
One thing you can do is use the Calculate Value tool. This is a tool we will cover later – it is
an extremely powerful tool. It receives an input, performs a calculation or transforms the
data into a chosen output which can then be passed into another process.
g. On the ModelBuilder tab go to Insert group > Utilities > Calculate Value.
h. Move the Calculate Value tool to the right of the For iterator.
j. Double click the Calculate Value tool to display the dialog box.
The Calculate Value tool receives a value in the Expression parameter; it is capable of then
performing a calculation in the Code Block area before passing the result out via the Data
Type parameter.
___________________________________________________________________________
___________________________________________________________________________
k. Change the Data Type from Variant to Cell Size XY and press the OK button.
l. Connect the Output Value of the Calculate Value tool to the Resample tool.
As the tool runs notice that the Value increments by values of 15 from 30, 45 all the way to
90.
o. Once the model has finished close the geoprocessing progress dialog, refresh the
project’s default geodatabase and inspect its contents.
Question 7: Based upon the values you entered into the iterator, how many output datasets
would you expect to see?
___________________________________________________________________________
___________________________________________________________________________
So how can five separate contour datasets be produced marking one for each iteration?
You know currently that the datasets will be overwritten with each iteration – this is what
you want for the intermediate resampled raster dataset, but you want the final dataset to be
unique. This is where you will apply the in-line variable substitution.
The current value processed by the iteration is held in the Value variable. This variable can be
surrounded by percentage signs (%Value%) and added to an output dataset to create the
unique output for that iteration.
This will add an ‘underscore’ to the name of the dataset followed by the current value stored
in the Value variable.
You will notice that 5 output contour datasets have been created as well as the intermediate
resampled raster dataset. The unique names are due to the %Value% being appended onto
the output name.
In this exercise you have created a model and added an iterator to it which allows the
processing of a resampling / contour creation workflow a set number of times. You have
used inline variable substitution to make sure that each output is unique, which is a
requirement for any output created by an iterator.
You have a couple of options now. You can look at the following optional step, followed by a
quick challenge step or you can go and have a break.
End of exercise
a. First of all, delete all of the datasets which are found inside of the SoCal default
geodatabase.
d. Select the current workspace but leave the name of the output dataset.
If you feel like it have a go at the challenge step. This will be a test to see if you can
remember how to obtain user input to change the To Value.
So…
a. Add an additional variable to the For iterator which represents the To Value and
make it into a model parameter:
d. For the To Value number enter 105 and run the model.
Once the model has finished processing you can add the datasets onto the map for your
inspection.
Notice that there are six contour datasets which have been created – the additional one is
created because you have changed the To Value to 105.
End of exercise
Introduction
ModelBuilder has been described as a visual programming language. If you have carried out
some programming using any language then you have probably noticed that ModelBuilder
shares terms which are common to languages such as C#.net, VB and Python.
Languages have the concept of variables, syntax checking (validation) and looping. One
thing which has not been covered yet, which computer languages share, are the ability to
perform logic tests, such as “does this dataset exist”, “if this condition is true then run this”.
ModelBuilder also possesses the ability to perform these (and other) sorts of test.
ModelBuilder also supplies some so-called utility tools. Think of these as ‘helper’ tools – for
example the Calculate Value tool.
In earlier versions of ModelBuilder you would have had to have written a Python script to
achieve the same functionality which is now available in ModelBuilder.
This section will lead you through what tools are available and how to use them.
• Utility tools
• Logical tools
Calculate Value
The Calculate Value tool returns a value based upon a Python expression.
This is an incredibly powerful tool in that it receives a value(s), possibly passed in by the
user, and performs a calculation and returns a value back to the model which can then be
used in the next model process.
Variables created in ModelBuilder can be used by this tool, but variables desired for use in
the expression parameter cannot be connected to the Calculate Value tool. To use them in
the expression, enclose the variable name in percent signs (%) using inline variable
substitution.
The above model calculates a buffer distance. The Calculate Value tool receives the circle
circumference and then creates the radius (buffer distance) which is passed to the Buffer
tool.
Collect Values
The Collect Values tool is designed to collect output values of an iterator or to convert a list
of multivalues into a single input. The example below employs the Collect Values tool in a
sub model (more about embedding a model in an existing model later on in the course). The
output of Collect Values can be used as input to tools like Merge, Append, Mosaic, and Cell
Statistics which are found in the parent model.
The output of the Collect Values tool is Output Values. It is a multivalue of rasters and is
input to the Mosaic To New Rasters tool.
Another use of the Collect Values tool is for removing output parameters from the tool
dialog and still have the output added to the display. For example, suppose your model uses
the Buffer tool and the output of Buffer tool is a model parameter. When you run your
model from its tool dialog, the tool dialog displays this parameter and the user of your
dialog can change the location where the output of Buffer is written. But what if you don't
want the user of your dialog to change this location? That is, you want to write it to a
specific location they cannot change.
The solution is to change the output of Buffer so it is not a parameter and connect the
output to the Collect Values tool. Then make the output of Collect Values a model
parameter. When the model is run from the tool dialog, the parameter is not displayed in
the dialog and your user cannot change it. Yet, because it's an output parameter, it gets
added to the map.
The Summary Statistics tool creates a table which will only ever have one record in it. It
might contain the sum of a series of selected population values as specified by the input.
The value in the specified field is then extracted by the Get Field Value tool.
Parse Path
The Parse Path tool parses the input into its file, path, name, or extension derived variables.
The output can be used as inline variables in the output name of other tools.
Consider the following: if the input to the Parse Path tool is C:\Data\InputFC.shp, then in
the model below, multiple Parse Path tools are added to the model to extract the desired
portion of the Input.
Select Data
The Select Data tool selects data in a parent container, such as a folder, geodatabase or
feature dataset.
In the example below, the model copies two shapefiles to a geodatabase and merges one of
these feature classes with another feature class. The Select Data tool is used to select one of
the two feature classes in the geodatabase and pass it to the Merge tool.
A process can be made to run after another process by making the output of the first
process a precondition to the second process.
The model contains two separate processes; the first process must execute before the
second process. If the model is executed as is, there is no way to control the order of
operations; the Clip tool may execute before its output location is even created, resulting in
an error.
At some point in the model it may be necessary to merge the different branches together.
And stop execution of the model.
The following tools all require the boolean outputs to be set as a precondition.
Name Description
If Data Exists Evaluates if the specified data exists.
If Field Exists Evaluates if the input data has the specified fields.
If Selection Exists Evaluates if the input data has a selection and if a
certain number of records are selected.
If Row Count Is Evaluates if the row count of the input data matches a
specified value, for example, Is there more than one row
in a table?
If Coordinate System Is Evaluates if the input data has the specified coordinate
system, such as WGS 1984 Web Mercator.
If Data Type Is Evaluates if the input data matches the specified data
type, for example, check to see if the input is a feature
class or a shapefile.
If Feature Type Is Evaluates if a feature class is of the specified feature
type, such as point, polyline, polygon etc.
If Field Value Is Evaluates if the values in an attribute field match a
specified value, expression, or second field.
If Spatial Relationship Is Evaluates if the inputs have a specified spatial
relationship, for example, do any of the listed buildings
intersect a conservation area?
If Expression is Evaluates whether a Python expression is true or false
If Value is Evaluates an input value compared to a single value, a
list of values, or a range of values using a defined
comparison operator
Help > Analysis and geoprocessing > Geoprocessing > ModelBuilder > ModelBuilder toolbox
> Logical
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Question 3: Which logic tool would I use if I want to identify if the input dataset is a raster?
___________________________________________________________________________
___________________________________________________________________________
Question 4: Write down a scenario in which you would use the If Dataset Exists logic tool.
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
If Field Exists
This tool checks to see if a particular attribute field (OWNER) exists. If it does not (False
condition) then the OWNER field is created and populated with the expression in the
Calculate Field tool.
The field_test_type parameter allows for different scenarios to be applied; for example – a
test to see that the input table has at least one expected field.
The boolean output of the If Field Exists tool has to be set as a precondition to the
downstream tools for those to execute if either the precondition is set to True or False.
If Selection Exists
The If Selection Exists tool checks to see if a selection set exists in a layer or table view.
There are many options available regarding how the selection criteria is tested:
In the model above the “Is Greater Than” option was selected and then a Count of 0 applied
so if a selection was made of any number then the precondition is set to True for the If
Selection Exists tool.
This tool does not make a selection or evaluate an SQL expression or where
clause. It simply checks if a selection set matches a specified value. If you
need to make a selection then you should use the Select Layer By Attribute
tool to make a selection in ModelBuilder.
If Spatial Relationship Is
The If Spatial Relationship Is tool determines if the inputs have a specified spatial
relationship. The spatial relationships are the operators associated with the Select Layer By
Location tool:
In the dialog below the test is to see if any Schools are intersected by the Floods feature
layer. If some schools are intersected (the Selection Condition is set to Greater Than 0) then
the precondition is set to True.
It is important to note that the If Spatial Relationship Is tool does not select any features –
that is why the Select Layer By Location tool is used. The If Spatial Relationship Is tool just
evaluates a spatial relationship with the additional Selection Condition.
Name Description
Merge Branch The tool merges two or more logical branches
(created by, for example, If Data Type Is) into a
single output.
Stop Stops processing if all inputs values meet the
specified condition of True or False.
You will cover how to work with a Python script tool in the next section.
For each run of the model only one branch of the model will run and produce an output.
In the model below the Merge Branch tool is used to merge the two separate branches. The
False branch creates the OWNER field on the existing Listed Buildings layer while the True
branch is processed when the OWNER field already exists and so the Listed Buildings layer is
passed into the Merge Branch tool.
Once a single branch has been created downstream tools are then applied to within that
single branch as opposed to having the same tool run on each separate branch.
In the example above, the For iterator has been used to iterate values from 500 to 4000 and
incrementing by a value of 500. At the first iteration, the Value variable is 500, then 1000,
then 1500, and so on. This value is used as a buffer distance.
The Summary Statistics tool is used to calculate the sum area of all the polygons; the Get
Field Value tool is used to get the value from the summary statistics table.
The Calculate Value tool is used to calculate a Boolean true if the Sum Area value exceeds
40.
The Stop tool is set to stop model execution if the condition set in Calculate Value tool is
true. The model iterates for each value, and at the fourth iteration, in this example, the total
area of all polygons exceeds 40, making the condition true. The Stop tool exits the model at
this point.
In this exercise you will create a model which will extract all the feature classes from a
geodatabase which have a feature type of point or polyline and export them as shapefiles.
The finished model should look like the one displayed below:
a. Start ArcGIS Pro and login using the credentials you were supplied with earlier.
b. Create a map based project called UtilityLogic and store it in the following location:
C:\EsriTraining\MBOP\UtilityTools
Name: ProcessFCs
Label: Process Feature Classes to Shps
The feature classes you are going to process are in the Aylesbury file geodatabase.
C:\EsriTraining\Database\Buckinghamshire
There are quite a few feature classes in the Aylesbury geodatabase contained in this folder.
You could export the feature classes individually or you could create a model which can be
re-used later.
Question 1: How many point feature classes are in the Aylesbury geodatabase?
___________________________________________________________________________
___________________________________________________________________________
Question 2: How many polyline feature classes are in the Aylesbury geodatabase?
___________________________________________________________________________
___________________________________________________________________________
Before you do that you will add a tool which creates a folder. This folder is where ultimately
the exported feature classes will be stored.
a. In the Geoprocessing pane locate the Create Folder tool and drag it onto the canvas.
b. Right click the Create Folder tool and choose Create Variable > From Parameter >
Folder Location.
c. For the default value for the Folder Location variable enter
C:\EsriTraining\MBOP\UtilityTools
d. Double click the Create Folder tool and for Folder Name enter Points.
You will now add the iterator. An iterator is available which allows you to process the feature
classes in a given geodatabase.
Question 3: What iterator should you choose to process the feature classes?
___________________________________________________________________________
___________________________________________________________________________
f. Add the Iterate Feature Classes tool to the model canvas and move it to the right of
the Points variable.
g. Create variables for Workspace or Feature Dataset (HINT: Right click the iterator >
Create Variable > From Parameter).
j. Connect the output of the Create Folder tool (Points) to the Iterate Feature Classes
tool and choose the Precondition.
This means that the Create Folder process will run before the Iterate Feature Classes tool.
The Iterate Feature Classes tool does not directly rely on the output of the Create Folder tool
for it to work.
___________________________________________________________________________
___________________________________________________________________________
Question 5: What use could the Name variable be put to later on in the model?
___________________________________________________________________________
___________________________________________________________________________
b. Connect the FeatureClass variable to the Copy Features tool and choose the relevant
connection parameter.
Question 6: Where is the location which the Copy Features tool writes out to?
___________________________________________________________________________
___________________________________________________________________________
As you can see the tool creates an output in the same location. This means that each feature
class created for each iteration will have the same name; each new feature class will
overwrites the previous feature class. You need to create a unique output for each iteration
of the model.
The Points variable contains the location of the new Points directory so this can be used for
the output location.
c. Move your cursor over the Points variable to see the output location for the
shapefiles.
___________________________________________________________________________
___________________________________________________________________________
Question 8: What variable contains the string name of the currently processed feature
class?
___________________________________________________________________________
___________________________________________________________________________
The output for the Copy Features tool can be built by using in-line variable substitution based
upon the answers to questions 7 and 8 with .shp added at the end.
You will need to include a backslash \ between the Points and Name
variables.
Notice the Points folder which was created by the Create Folder tool.
You will see that all of the feature classes from the Aylesbury file geodatabase have been
exported as shapefiles to this folder.
The tool implements Boolean logic; if the passed in feature class’s feature type matches the
feature type of the tool then that will evaluate to Boolean true, otherwise Boolean false will
be returned.
You will add it to the model so that it accepts the FeatureClass variable from the Iterate
Feature Classes tool and then based upon the logic test outcome it will then connect to the
Copy Features tool.
a. On the ModelBuilder ribbon, locate the Insert group and choose If Feature Type Is
from the Logical menu.
c. Right click the If Feature Type Is tool and create a variable from parameter based on
the Feature Type.
e. Connect the FeatureClass variable to the If Feature Type Is tool choosing the relevant
input parameter choice.
The tool has two outputs – true and false. The true branch will run when the feature class
being processed has the same feature type as the tool’s feature type. The false branch will
run when the feature classes feature type is not a point feature type.
Question 9: Which branch should the Copy Features tool be connected to?
___________________________________________________________________________
___________________________________________________________________________
g. The model might look a little messy so use the Auto Layout button to rearrange the
components.
h. Rearrange the variables and tools so that it looks like the following:
Once the model has run you are ready to inspect the output.
You will notice that it is comprised of many shapefiles; each one is a point shapefile.
The model has sifted through the Aylesbury geodatabase and copied the point feature
classes into the point folder as shapefiles. You have fulfilled your brief.
You may have noticed that the Iterate Feature Classes tool has a Feature Type argument.
You could have set that to a Point….. but where is the fun in that?
l. If you have time then perhaps have a go at Scenario A? Otherwise close ArcGIS Pro
down.
End of exercise
Introduction
So far you have learned how to create some basic models and to that, you have added
greater complexity in the form of iterators, logic and utility tools.
In this final section you will have a look at how you can extend your models by embedding
an existing model inside of a model, running your model using ArcGIS Pro’s task scheduling
functionality. As well as those topics you will also have a look at how you can interactively
create features for input into a model and have a look at how model feedback can be used
for iterative processing too.
Learning objectives
After completing this lesson, you will be able to perform the following task:
However, if one of your model parameters is a feature set, feature layer, or table view
datatype, you will be able to select existing map layers from the Contents pane, browse to
datasets, or interactively enter new features on the map.
Clicking the interactive input tool displays a drop down box of points, lines, polygons and
multipatch. These are valid entries for the tool.
In the example below the BristolBusStops layer file is added as a property of the feature set
which indicates that the only type of geometry, and symbology, which can be used for input
into the model will be a point.
A feedback loop is made by connecting an output variable of one process to the input
variable of the same process. The model knows that when the output is connected to the
input it is a feedback loop and automatically creates a dotted blue feedback connector line.
Every time the tool iterates, the output variable will be used as input for the next iteration.
The model will produce one output per iteration. In-line variable substitution is then used as
part of the name for the output dataset if you do not want the output dataset to be
overwritten.
The other reason is to accommodate multiple iterators in a workflow. Remember that only
one iterator per model is supported. Nesting models allows for workflows which require
multiple iterators to be present.
The tools you want to run once should be placed in a separate model from those tools
which are to be run more than once. In this situation, all tools that need to run multiple
times should be placed in one model with a model iterator and used as a sub-model. The
tools that only need to be run once should be placed in the main model, which calls the
iterating sub-model.
Provide default values to your sub model when you are testing.
The SubModel contains another iterator, Iterate Feature Classes, which processes the point
feature classes based upon the passed in workspace. The currently processed feature class
is then buffered. Once that iteration has finished in the SubModel then flow returns back to
the next iteration in the Iterate Workspaces tool in the MainModel model.
• Use MS-Windows Task Scheduler. For more information on how to do this then
please see Appendix 1.
• Use the scheduler available within ArcGIS Pro.
You can schedule geoprocessing tools to run within ArcGIS Pro. This relates to the System
tool, Python Script and Toolbox tools, and Model tools.
On the Schedule: dialog specify the Name, how often the tool will run (once, minutes, hours,
daily, weekly or monthly), and when the model will first run.
Every time the tool runs you have the option of overwriting the original output or creating a
new unique output based upon the date and time the scheduled tool ran. If you wish to
create new output then use the timestamp variable %t%. So If the tool ran at 15:35 on 22nd
April 2021 and it created a new PlanningApps feature class then the output would be of the
form:
In this final exercise you will investigate how to embed a model to an existing model and in
doing so you will bring together many of the techniques you have learned in this course.
You will create a model which will iterate over a number of file geodatabase workspaces.
This is the parent model.
You will also work with an existing model which processes each feature class in a workspace
and buffers the features accordingly. This will be the child model.
You could run both models independently of each other but it means that you would be
running the “buffer” sub-model many times once the first model has run which isn’t
particularly efficient, so you will embed the existing child “buffer” model into the parent
“iterator” model.
The Buffer Feature Classes using an Iterator process is the sub model which will be added to
the parent model.
a. Open ArcGIS Pro, create a new blank Catalog project called EmbedModel and store
it in the following location:
C:\EsriTraining\MBOP\AdvancedTechniques
e. For the Iterate Workspaces tool, add a Folder variable and set its value to:
C:\EsriTraining\Database\Buckinghamshire
f. For the Iterate Workspaces tool create a Workspace Type variable and set its value
to File Geodatabase.
In this step you have created a basic model. In a future step a sub-model will be added to this
parent model.
a. In the Catalog tab expand Folders > EsriTraining > MBOP > AdvancedTechniques.
b. Expand the ModelToAdd toolbox and edit the Buffer Feature Classes using an
Iterator model.
c. Spend a few moments examining the model and then answer the following
questions:
___________________________________________________________________________
___________________________________________________________________________
Question 2: How is a unique output created from the Buffer tool created?
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Currently the model will buffer all point feature classes within the Bristol_Centre file
geodatabase. A unique output feature class is created and is stored in the
C:\EsriTraining\MBOP\AdvancedTechniques\OutputGDB.gdb and all output feature classes
have “Buff_” placed in front of them.
Now that you have an understanding of what this child model does you are ready to add it to
the parent model.
a. Drag the Buffer Feature Classes… model into the Iterate Workspaces model.
You may have noticed that the Iterate Workspaces tool outputs to a workspace and that the
Iterate Feature Classes iterator has a workspace as an input.
To pass the current workspace, which is being processed in the parent model, into the Buffer
Feature Classes … child model you will need to connect the parent model’s output workspace
to the input workspace of the child Buffer Feature Classes… model.
b. Try to connect the Workspace output to the Buffer Feature Classes… process.
For the model to communicate with the other one you need to connect to a workspace.
You will make a change in the Buffer Feature Classes… model to allow a useful connection to
be made.
c. If you have made a connection between the two items then delete it.
d. Delete the Buffer Feature Classes… tool in the Iterate Workspaces model.
e. In the Buffer Feature Classes… model locate the Workspace variable and make it a
parameter.
h. Drag the Buffer Feature Classes… model back into the Iterate Workspaces model.
You will see that the model with its input parameter (Bristol_Centre)is added.
j. Connect the Workspace variable of the parent model to Buffer Feature Classes… tool
by choosing the Workspace option as the input parameter to the model.
As you can imagine the model is iterating over each file geodatabase in the Buckinghamshire
folder and buffering all the point feature classes in each file geodatabase.
___________________________________________________________________________
___________________________________________________________________________
The output geodatabase contains the buffered point feature classes from the geodatabases.
Notice, though, that the point feature classes in the feature datasets are not processed - you
would need to use an Iterate Datasets tool to achieve that.
This is an ideal technique to use when you wish your model to run daily, weekly etc when you
may not be able to run the model during the working day, or because a workflow demands
that datasets are refreshed at certain times of the day.
Creating a scheduled task in ArcGIS Pro will also create a scheduled task in Windows Task
Schedular.
You will also add the %t% timestamp to the name of the output feature classes the child
model creates to help identify when the scheduled task ran. This will also help provide
unique output should you ever wish to run the model again as a scheduled
d. Add the following to the end of the BufferedFC output value: _%t%
f. In the Toolboxes > EmbedModel.atbx double click the Iterate Workspaces model
tool to display the tool dialog.
There are no parameters to fill in on the dialog as all of the required parameters for the tools
in the model have been filled in already.
g. On the Run button click the split option and choose Schedule.
h. Set the Begins On value to one minute from now and press the OK button.
i. To view the progress of scheduled tasks then open the History pane (HINT: Analysis
tab > Geoprocessing group).
This will display the results of your scheduled tools. You can view whether or not the process
ran without any errors, messages – all the things you would expect to be able to see when
you run a tool:
End of exercise
Term Description
Connector Lines connecting variables to tools.
Data Type In a script \ model tool the Data Type refers to the expected
data passed in or passed out of a script or model.
Data Variable Stores an input or derived data.
Derived Data Data created from geoprocessing tool.
Derived Values Standard types created by tools, for example, the Calculate
Value tool.
Direction In a script \ model tool the Direction refers to whether data
exists (input) or is created (output).
Element A component part of your model. These can be geoprocessing
tools, types of variables and connector lines.
Feature Set A datatype that allows a user to intuitively add features to a
map and use them as inputs into a model.
Feedback Connector Output of one process which is used as the input into a previous
process
in_memory Legacy memory based workspace for use with ArcMap. Use the
memory workspace when working with ArcGIS Pro.
Input Data Normally pathways and datasets.
Input Values Basic data types of numbers, strings and Booleans.
Intermediate Dataset Data created by a tool which is then used as an input into a new
tool. Tends to be temporary in nature.
Iterator Allows batch processing of feature classes, rasters, workspaces
etc in a model
memory New memory based workspace for ArcGIS Pro to support
output feature classes, tables and raster datasets. Subtypes and
domains are supported.
Model A diagram containing a collection of tools, with their associated
variables, which replicates an organisation’s workflow.
Model Tool A model that resides and run from inside a toolbox
Parameter Allows user defined data stored inside a variable for use in a
model, such as an input feature class or the location of an
output workspace.
Create a
simple Create a Task
Specify the Specify the Manage the
Python script in Windows
Task Action Task Trigger Task
to call the Scheduler
model
You will need to make sure that Python and the ArcPy site package are installed on the
machine running the Task Scheduler as well as providing the machine access to your model
and associated data.
import arcpy
arcpy.ImportToolbox(r"C:\PathTo\myToolbox.atbx")
arcpy.myModelName(r"c:\pathToInput\inputFolder", r"C:\pathToGdb\output.gdb")
The model (myModelName) is part of the geoprocessing framework and is called directly
from the ArcPy site package. In the example above the model has two parameters which are
passed into the model.
© ESRI (UK) Ltd Page 136
Step 2: Create the Task in Task Scheduler
Windows Task Scheduler allows you to run the script (and in turn, the model) at a specified
time.
It is simple enough to create the Task and provide a name for it.
Set the pathway to the Python installation via the Program/script section in the Create Task
dialog box and point it towards the following location:
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
This is the default file path for the version of Python used in ArcGIS Pro and ensures that the
script is able to execute the ArcPy code.
In the Add arguments (optional) option in the New Action window, add the path to your
script file; it must be enclosed in quotation marks:
Once it has run it will be displayed in the Task library (you may need to refresh it)
Answer: Auto Layout arranges the elements in your model in the most pleasing way possible
while Fit To Window will zoom to the full extent to fit all elements in the display.
Answer: The Insert group allows you to add elements on to the ModelBuilder canvas.
Answer: The Lock Element button prevents elements from being included in the Auto
Layout operation.
Answer: The Group button allows you to group together model processes, name the group
and hide (collapse) the elements in the group.
Answer: There are 3 types of label: A free standing label; label associated with a tool, a label
associated with data.
Answer: You can use the Undo button on the Quick Access Toolbar.
Question 1: What is the current value for ‘Allow geoprocessing tools to overwrite existing
datasets’?
Answer: The check box is ticked which means that any existing datasets can be
overwritten by geoprocessing processes.
Answer: The model buffers the Major Bristol Roads dataset and then uses the output of
the Buffer tool to clip the Planning Applications features.
Question 3: What is the distance to which the Bristol roads are being buffered to?
Question 4: On the Clip tool what is the name of the Input Features and what do they
represent?
Answer: The name of the Input Features is Planning Applications and they represent the
features to be clipped.
Question 5: What is the name of the clipped output dataset and which location is it written
to?
C:\EsriTraining\MBOP\ModelBuilderBasics\BufferAndClip\BufferAndClip.gdb\
Answer: It was created by the Buffer tool. It is then used as an input into the Clip tool.
Answer: Only one iterator per model can be used. If you want to have more than one
iterator in a workflow then you will need to embed a model in an existing model.
Question 3: How might you provide a unique name to the output of a tool which is affected
by an iterator?
Question 4: What iterator would you choose if you wanted to run a workflow a specific
number of times?
Answer: A FOR iterator allows you to run a model an explicit number of times
Question 5: How would you iterate over each row or feature in a table or feature class?
Answer: The Iterate Row Selection / Iterate Feature Selection iterators allow you to process
each row or feature.
Answer: From the ModelBuilder ribbon go to the Insert Group and choose Iterators.
Answer: Not all of the mandatory parameters have been filled in.
Question 4: What required parameter does the tool need to be populated with?
Answer: The Contour interval is the only required parameter which needs to be filled in.
Once a value has been entered then the model process will be in a ready to run state.
Answer: The Value variable holds the current value which the For iterator is processing.
Answer: The current Data Type is set to Variant. This indicates that the tool does not know
what the data type will be based upon its current information.
Question 7: Based upon the values you entered into the iterator, how many output datasets
would you expect to see?
Answer: You would expect to see five output contour datasets – one for each iteration
(30, 45, 60, 75, 90).
Now that you have an understanding as to what some of the logic tools do, see if you can
answer the following questions or identify a useful scenario in which to use the tools.
Question 3: Which logic tool would I use if I want to identify if the input dataset is a raster?
Answer: The Is Data Type tool could be used to identify if an input dataset is a raster dataset
or not
Question 4: Write down a scenario in which you would use the If Dataset Exists logic tool.
Answer: You might want to see if a particular named dataset exists and perform a field
calculation on it. This is because the field calculation might be reliant on the existence of
some existing attribute fields that are found inside of the dataset.
Question 5: What tool should be added to the model to complete the logic flow?
Answer: The Merge Branch tool is the missing tool, as it brings both strands of the model
together.
Question 1: How many point feature classes are in the Aylesbury geodatabase?
Question 2: How many polyline feature classes are in the Aylesbury geodatabase?
Question 3: What iterator should you choose to process the feature classes?
Answer: The FeatureClass derived variable stores a reference to the actual feature class that
the iterator is currently processing.
Question 5: What use could the Name variable be put to later on in the model?
Answer: You can use the contents of the Name variable, which is a string (the name of the
feature class that is being processed) for in-line variable substitution.
Question 6: Where is the location which the Copy Features tool writes out to?
Answer: The Name variable contains the string representation of the currently processed
feature class.
Question 9: Which branch should the Copy Features tool be connected to?
Answer: The Copy Features tool should be connected to the true strand as you only want to
copy the point feature classes to the Point folder as shapefiles.
Question 2: How is a unique output created from the Buffer tool created?
Answer: In-line variable substitution is used to first of all specify the location of the
destination file geodatabase, and then the unique name of the output feature class.