We’ve been compiling a list of "What I wish I had known about ModelBuilder before I started using it". Here are a few things that made the list:
- Create personalized tools in ModelBuilder: Until a few days ago, I thought the ModelBuilder editing window (the one that you access when you right click a model that you made adn select Edit) was the only environment I could interact with. For years, I dragged and dropped folders and features into the tools of the ModelBuilder editing window before clicking the black triangle to run the processes. Recently I discovered that ModelBuilder is the editing environment to create a custom tool from existing tools and personalized parameters and conditions. But then when you double click the tool in the ArcToolbox window, you get right into the user interface for the tool.
- Controlling the flow: Setting preconditions and parameters in ModelBuilder guarantees that the geoprocessing operations will run in the correct order. For example, I wanted to create a tool that projected a dataset into a new personal database, which I set as a parameter of my model. Before projecting the feature dataset, the new personal geodatabase had to be created. I relayed this information to ModelBuilder by right clicking the Project tool and setting the new personal geodatabase as a precondition. I also had several other parameters in my model, including a coordinate system and a geographic transformation method. Since the geographic transformation depends on the selected coordinate system, I set the coordinate system as a parameter before I set the geographic transformation method as a parameter.
- In-line variable substitution: In-line variable substitution is useful if you have a model parameter that serves as a precondition to another process in your model. Using the example above, I wanted to create a tool that projected a dataset into a new personal database, which I set as a parameter. The name and location of the new personal geodatabase is only defined when the model is run, so I had to use in-line variable substitution to parse the processes together within the same model. With a precondition set on the new personal geodatabase, the output notation for the projected dataset is %new personal geodatabase%\ProjectedDatasetName. Note that the new personal geodatabase name is enclosed with the percent signs (%new personal geodatabase%).
- Editing tool documentation: The tool and parameter descriptions for a model can be edited in ArcMap by right-clicking the model and selecting Edit Documentation. You can add as much information about the tool/model as you like. The most useful documentation for me is the Abstract and Parameters Dialog Reference. The Abstract allows you to fill in information about what the tool does. The Parameters Dialog Reference allows you to fill in information about the parameters and can be populated by selecting Dialog Reference under the parameter name. You can then click one of the icons to add paragraphs, links, illustrations, code and formatting options. You can also documentation for the parameter by right clicking the tool in the Model Builder window and selecting Edit Documentation. Remember to click Finish or OK when you are done editing. Now, when you double-click your model, you will see the Abstract and the content that you added for each parameter of the model.
- Model environments and overrides: There are three places to where you can set your model Environments. One is at the ArcToolbox level, another is at the model/tool level, and the third is at the process level. The Environments setting at the process level in ModelBuilder will override the Environments setting at the model/tool level. The Environments setting at the Model/Tool level will override the default at the ArcToolbox level. This gives you the flexibility to define general Environment settings for the majority of processes in your model, but tailor specific settings to specific processes
- Current workspace: This is the directory from which inputs are taken and into which outputs are placed. If you set this (right click the tool in ArcToolbox, click Properties, click on the Environments tab, click General Settings, click Current Workspace and point to the directory you want to use), then your tool will automatically point to the same directory every time so you don’t have to keep navigating to the location. When I create a new tool, I also create a "Tooldata" folder in the directory that stores my tool. It contains some sample data which, when I set it as my Current Workspace, is used as input and it is where the outputs of the model will be placed. That way the tool knows where the data for inputs and the location for outputs should be.
- Intermediate data: When you run a model, output data is created for each process in the model. Some of the data created is of no use after the model is run since it was only created to connect to another process that creates new output – this is called “intermediate data”. To set a data variable to be intermediate, right-click the data variable and check the option to set it as intermediate data. If it is intermediate data, it will be written to the scratch workspace.
- Scratch workspace: This is the directory for temporary storage of execution results that are created with an auto-generated name. As with the Current Directory, when I create a new tool, I also create a “Scratch” folder in the directory that stores my tool and the Tooldata folder. I set this as my Scratch Workspace. That way the tool knows where the temp files should be placed. This way I can easily delete them or use the model to delete them when I am done with the processing.