A geoprocessing model is composed of model elements that are connected to form processes. You can add geoprocessing tools, data, and other elements, connect them to each other, and modify the elements' size and position.
You can add data to a model by dragging and dropping data and layers from the following panes:
- Drag and drop datasets such as feature classes, tables, and rasters into ModelBuilder from the Catalog pane.
- Drag and drop map layers into ModelBuilder from the Contents pane. When working in ModelBuilder, the Contents pane lists layers from the last active map or scene.
When you add data to a model, a data variable is created as a blue oval. Data variables contain a description of the data, not the data itself. ModelBuilder stores descriptive information about the data in the variable, such as spatial extent, field information, and coordinate system, as well as the path to the data.
To view or change the value of a data variable—a path to the dataset or a layer name—double-click the variable or right-click the variable and click Open. The dialog box that opens will display the following:
- The name and data type of the variable in the title bar.
- The value of the variable in the Value tab. You can change the value here.
- Some variables will have a Properties tab, on which you can set a Template layer that will be used to symbolize the data when the variable is added to the display, and is also used to specify the shape type, symbology, and other properties of feature set variables.
You can add tools to a model using the following techniques:
- Start typing directly in ModelBuilder to open the Add Tools To Model dialog box and search for a specific tool. Double-click the tool to add it to the model.
- Use the Tools menu in the Insert group on the ModelBuilder tab to search for a specific tool, and double-click the tool to add it to the model.
- Drag and drop geoprocessing tools into ModelBuilder from the Geoprocessing pane.
- Drag and drop geoprocessing tools into ModelBuilder from toolboxes in the Catalog pane.
- Drag and drop geoprocessing tools into ModelBuilder from the geoprocessing history.
When you add a geoprocessing tool to a model, a rectangular tool element is created, as well as related output variables. Both the tool and the output variables are typically gray when added because the tool is not yet ready to run. Once the required tool parameters are specified, the tool changes to yellow, indicating the process is ready to run.
Connect data and tools
You can specify the data or other parameter settings for a geoprocessing tool to use by making a connection between the variables and tools in the model. There are two primary ways to make connections: draw a connection interactively, or open the tool in the model and specify input parameters using model variables, map layers, or browsing to a dataset.
You can connect any variable to one or many tools.
Draw a connection interactively
- Place your cursor over the variable that you want to connect to a tool.
The cursor changes to the connection icon .
- Click and hold the left mouse button while you move the cursor to the tool to make a connection.
- When the cursor is above the tool, release the mouse button and select the tool parameter to which the variable should be connected.
A connection is made between the variable and the tool.
Open the tool to specify inputs
- To specify the parameter settings for a tool in the model, double-click the tool or right-click and click Open.
- You can specify parameter settings for the tool just as you would when running a tool in the Geoprocessing pane.
- Select map layers or model variables from a list.
- Browse for a dataset.
- Fill in the parameter using other controls such as Extent or Query Builder.
- Spaces and special characters in the input and output values will show an error on the Geoprocessing pane or will be replaced by an underscore when the tool executes.
- If the tool uses %scratchGDB% in the output path for a parameter, this project scratch geodatabase will be created if it does not exist during execution.
- To write the output to the scratch workspace set at the model environment level, use %scratchworkspace% in the output path of a parameter.
In some cases, a tool parameter will not provide a list of model variables to select. In these cases, use one of the following alternatives:
- Right-click the tool in the model and click Create Variable > From Parameter then select the tool parameter by name for which to make a variable.
- Insert a new empty variable using the Variable button in the Insert group on the ModelBuilder tab, select the appropriate data type for the tool parameter, specify the variable value, then manually draw a connection from the variable to the tool parameter.
Create a model from the geoprocessing history
Tools run from the Geoprocessing pane are added to the project's geoprocessing history. The tools listed in history can be added to a model using the Add to Model command or by dragging and dropping them into an open model. The tools will parse through the inputs and outputs of all the existing and incoming elements and automatically create connections to the correct elements according to the following rules.
- Tools with defined paths for the input and output are matched and connected based on the exact path. For example, the output of Tool 1 with the value of C:\Temp.gdb\Buffers is connected with the input of Tool 2 that has the same input value of C:\Temp.gdb\Buffers.
- In cases where Tool 1 is run from the Geoprocessing pane, its output, C:\Temp.gdb\Buffers, is added to the Contents pane as the Buffers layer. This layer is then used as input to Tool 2. When Tool 2 from the geoprocessing history is added to a model, it is connected to any existing variables with the same value, Buffers. If there are no existing values, then the tool connects to the element where the name Buffers in the path C:\Temp.gdb\Buffers matches another variable. If no match is found, a new variable with the value Buffers is created in the model.
- In cases such as Add Field and Calculate Field, where the tools modify the input instead of creating a new output, when these tools are added to a model from history, the chronological order of the tools in the history is maintained. For example, geoprocessing history contains the Buffer tool followed by the Add Field and Calculate Field tools. When these tools are added to a model from the history, Add Field will use the output of Buffer as input, and Calculate Field will use the output of Add Field as input.
Setting tool properties
Tool properties can be set by opening the tool dialog box and specifying properties such as Precondition. The Tool Path property is read only, indicating the source of the tool. This source path can be copied by right-clicking the selected path and clicking Copy.
Resize and move elements
To resize any model element, select the element and drag any of its handles. To move any model element, select it, hover over the middle of the element until the move cursor appears, then drag the element to any location in the model.
The default names of tools and variables are automatically generated by ModelBuilder when you add the element. If the element name already exists in the model, it is appended with a unique number. To rename any model element to a unique name, right-click a model element and click Rename, type in a new name, and press Enter or click outside the rename box.
Changing the name of a variable does not affect the contents, dataset, or value of the variable. For example, a variable references the value C:\Data\Example.gdb\Roads. Renaming the variable from Roads to Streets does not change the dataset path, only the variable name.
If you have renamed a tool in a model, you can see the original tool name using the following steps:
- Double-click the tool to open it, or right-click the tool and click Open.
Both the new name of the tool and the original tool name will display in the title bar of the dialog box, for example, State Name: String.