Summary
The For tool iterates over a starting and ending value by a given value. It works like For in any scripting or programming language, running through a set number of items.
In this workflow, you'll create a simple model that identifies the impact of proposed roads based on vegetation type and proximity to the road. In the model, the roads are first buffered three times with distance values of 500 feet, 1,000 feet, and 1,500 feet. These distance values are derived from the For iterator. The buffer zones are then used to clip the vegetation data using the Clip tool to create a dataset of vegetation types within the buffer polygons. The Summary Statistic tool then summarizes the affected area by vegetation type within the buffer polygons around the proposed roads. The Collect Values tool collects all the outputs of the iterations and adds them to the Contents pane for display in ArcGIS Pro.
Prerequisites
If you are new to ModelBuilder, review the following topics:
Open the project
Download the project to use in this workflow. The project includes an input geodatabase, an output geodatabase, and a completed model.
- Open the Work with For iterator overview page.
- Click Download on the right side of the page.
- Right-click the downloaded IterateFor.zip file and extract it to a convenient location, such as C:\Temp.
- In the extracted folder, IterateFor, double-click the ArcGIS Pro project file, IterateFor.aprx.
The project opens to an empty map and will be used to view the results from the model you will create in this workflow.
- Explore the data in the Catalog pane, and click the Project tab if necessary. Browse to Folders > IteratorFor.
Add tools
You'll create a model in the MyProjectTools toolbox. To add tools to the model, complete the following steps:
- In the Catalog pane, click the Project tab if necessary. Browse to Folders > IterateFor > MyProjectTools.
- Right-click MyProjectTools and click New. Select Model to create and open a model.
- Add the For tool.
- Click the ModelBuilder tab.
- In the Insert group, click Iterators .
- In the Iterators list, click For.
The For iterator is added to the model. The iterator is unavailable since no parameter values have been provided.
- Add the Collect Values tool.
- Click the ModelBuilder tab.
- In the Insert group, click Utilities .
- In the Utilities list, click Collect Values.
The Collect Values tool is added to the model.
- Add the Buffer tool.
- Click in the model, and type Buffer to open the Add Tools To Model dialog box.
- Search for the Buffer tool.
- Double-click the Buffer tool and add it to the model.
- Add the Clip and Summary Statistics tools to the model, as described in the previous step.
Specify the tool parameters and connect the tools
After adding tools to the model, you need to specify the parameters for each tool.
- Double-click the For iterator to open the iterator's dialog box. .
- For From Value, To Value, and By Value, type 500, 1500, and 500, respectively.
- Click OK to close the dialog box.
When the tool runs, the model will output 500 for the first iteration, then 1000 and 1500.
- Double-click the Buffer tool to open the tool's dialog box.
- For the Input Features parameter, click the browse button and browse to the <Your Project Location>\IterateFor\Data.gdb geodatabase. Select the PlanA_Roads feature layer.
- For the Output Feature Class parameter, browse to the <Your Project Location>\IterateFor\ScratchCommon.gdb geodatabase and type BufferedFC_%Value%.
At run time, %Value%, which is the name of the output variable of the For iterator (light blue oval), will be replaced by the value of the variable, 500, 1000, or 1500.
Tip:
In ModelBuilder, the value or dataset path of a variable can be substituted for another variable by enclosing the substituting variable name in percent signs (%VariableName%). Substituting variables in this manner is called inline variable substitution
- For the Distance [value or field] parameter, choose the Linear Unit option; leave the distance blank and set the units to Feet.
- Leave the remaining parameter default settings and click OK to close the dialog box.
- Hover over the For iterator output variable Value. Click and drag to draw a connector line to the Buffer tool. Release the mouse and click Distance [value or field] on the pop-up menu.
- Double-click the Clip tool to open the tool's dialog box.
- For the Input Features parameter, click the browse button and browse to the <Your Project Location>\IterateFor\Data.gdb geodatabase. Select the vegtype feature layer.
- For the Clip Features parameter, click the drop-down arrow and select BufferedFC_%Value%.
- For the Output Feature Class parameter, browse to the <Your Project Location>\IterateFor\ScratchCommon.gdb geodatabase and type ClippedFC_%Value%.
At run time, %Value%, which is the name of the output variable of the For iterator (light blue oval), will be replaced by the value of the variable, 500, 1000, or 1500.
- Leave the remaining parameter default settings and click OK to close the dialog box.
A connection is created between the output value of the Buffer tool and the Clip tool.
- Double-click the Summary Statistics tool to open the tool's dialog box.
- For the Input Table parameter, click the drop-down arrow and select ClippedFC_%Value%.
- For the Output Table parameter, browse to the <Your Project Location>\IterateFor\ScratchCommon.gdb geodatabase and type AffectedVegetation%Value%.
At run time, %Value%, which is the name of the output variable of the For iterator (light blue oval), will be replaced by the value of the variable, 500, 1000, or 1500.
- For the Statistics Field(s) parameter, select Shape_area for the Field column, and Sum for the Statistic Type column.
- For the Case field parameter, select VEG_TYPE.
- Click OK to close the dialog box.
- Hover over the Clip tool output variable. Click and drag to draw a connector line to the Collect Values tool. Release the mouse and click Input Value on the pop-up menu. Follow the same procedure to connect the Summary Statistics tool output variable and the Collect Values tool.
It is good practice to rename the input and output variable names to be more meaningful instead of using the default variable name.
- Right-click the output of the Buffer tool and click Rename. Type Buffered FC for a new name. Similarly, rename all the variables, as shown in the finished model.
- To arrange the model elements, click the Auto Layout button on the ModelBuilder tab, and click the Fit To Window button to maximize the layout to the size of your model window.
Run the model
- Right-click the output of the Collect Values tool, and click Add To Display.
The output is added to the map.
- Click the Save button on the ModelBuilder tab to save the model.
- Click the Run button on the ModelBuilder tab to run the model.
The model iterates over all the distance values from the For iterator, buffers the input feature class for all the distance values, clips the feature classes, and summarizes the affected area by vegetation type.
- In the Contents pane, right-click the added tables and select Open to see which vegetation types would be most impacted by the proposed roads for each of the buffered distances.
- Close the model and ArcGIS Pro.