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 data and layers from the following panes:
- Drag datasets such as feature classes, tables, and rasters into ModelBuilder from the Catalog pane.
- Drag 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 appears displays the following:
- The name and data type of the variable in the title bar.
- The value of the variable on the Value tab. You can change this value.
- Some variables 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. You can also specify the shape type, symbology, and other properties of feature set variables on the Properties tab.
You can add tools to a model using the following approaches:
- In either the Geoprocessing or History pane, drag a tool to a model, or right-click a tool and click Add to Model.
- On the ModelBuilder tab, add model-specific tools by clicking the Iterators , Utilities , or Logical buttons.
- On the ModelBuilder tab, click Insert > Tools , and add geoprocessing tools and model-specific tools such as Iterators, Utilities, and Logical tools.
- Type directly in ModelBuilder to open the Add Tools To Model dialog box and search for a specific tool. You can add a tool to the model by double-clicking it. You can also drag one or multiple tools from the search results. The Add Tools To Model dialog box includes all geoprocessing tools and model-specific tools.
When you add a geoprocessing tool to a model, a tool element is created, as well as related output variables. Model elements are typically gray when added because the tool is not yet ready to run. Once the required tool parameters are specified, the tool changes color, 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 and map layers or by browsing to a dataset.
You can connect any variable to one or many tools.
Draw a connection interactively
To draw a connection interactively, complete the following steps:
- Hover over the variable that you want to connect to a tool.
The pointer changes to the connection pointer .
- Click and hold the mouse button while you move the pointer to the tool to make a connection.
- When the pointer 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, complete the following steps:
- Double-click the tool or right-click it and click Open.
- 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 in the Geoprocessing pane or will be replaced by an underscore when the tool runs.
- 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 the running of the tool.
- 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 does 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 to make a variable by name.
- 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, and 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. You can add the tools listed in the history to a model using the Add to Model command or by dragging 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 in which 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, 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 Buffers value is created in the model.
- In cases such as Add Field and Calculate Field, in which the tools modify the input instead of creating a new output, when these tools are added to a model from the history, the chronological order of the tools in the history is maintained. For example, the 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.
Read and set element 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. To copy this source path, right-click the selected path and click Copy.
Model paths can be read by hovering over the model view name.
To identify the data type of a model variable, open the variable's dialog box. The data type is listed next to the parameter name.
Resize and move elements
To resize a model element, select the element and drag any of its handles. To move a model element, select it, hover over the middle of the element until the move pointer appears, and drag the element to a 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 a model element to a unique name, right-click the model element and click Rename, type 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 renamed a tool in a model and you want to see the original tool name, double-click the tool to open it or right-click the tool and click Open.
Both the new name and the original name of the tool appear in the title bar of the dialog box—for example, New Name: Buffer—as shown in the following image: