By Aileen Buckley, Mapping Center Lead
We’ve been compiling a list of tips for various “What I wish I had known about …” topics. Here are a few things that made my list for what I wish I had known about Model Builder before I started using it:
- Create personalized tools in Model Builder: Model Builder 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 Model Builder 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 Model Builder 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 Model Builder 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.
- Intermediate data when you run a model in the Model Builder window: Intermediate data will not be deleted if you run the model from the Model Builder window. If you want to delete intermediate data after running a model in the Model Builder window, click the Model menu and click Delete Intermediate Data.
- Doc folder: This is a folder to store files related to the documentation for the tool. As with the Current Directory and Scratch Directory, when I create a new tool, I also create a “Doc” folder in the directory that stores files that relate to the tool documentation. For example, it is nice to include an annotated picture of the model from Model Builder in the documentation. You can store that picture file in the Doc directory.
- Store relative path names: When you set this (right click the tool in ArcToolbox, click Properties, click on the General tab, click the option to Store relative path names), then the paths in your model are defined relative to a current directory. For the Tooldata, Scratch and Doc folders that I described above, the tool will always know where to find them because I set this parameter, and I always place them in the same directory as my tool.
- Add the output to your display: If you want to add the final results to your display so you can see them immediately after the tool has run, right click the tool in ArcToolbox, click Edit, right click on the output of the tool and click on Add to Display. I sometimes also add intermediate results to my display so that I can see if the model is doing what I think it should. When I get the model to work like I want, I go back into Edit mode and turn off “Add to Display” for the intermediate results.
- Use option to overwrite data: This is something you do not actually set in Model Builder, but I really like it because then I can keep overwriting the output. On the top bar menu, click Tools, then click Options. Click the Geoprocessing tab and click the option to Overwrite the outputs of geoprocessing operations.