ModelBuilder Tips


 ArcGIS Tutorial

Main

ArcGIS Tutorials

I have a tendency to underutilized the built-in ModelBuilder.  I suppose it is probably because I generally do not have to run batch processes, or if I do, then I can right-click on the the tool and select Batch.

 


This is a bit tedious to fill out, but using copy and paste you can go through it pretty quickly.

I use ModelBuilder, mostly, to get a Python Script started.  It has a handy feature to export the model to Python (or VB) and this gets me going much quicker than by hand.  In a lot of cases, I use Python to do a batch process, like cyclying through all the feature classes in a folder.  Anyway, this isn't a Python tutorial (that will eventually be added to the GIS programming section).

This is meant to demonstrate an area of the ModelBuilder where you might not think of using it - to improve the existing tools.  To do this I will be using the Spatial Analyst Toolbox, because it gives a particularly nice demonstration on what I'm talking about.  If you don't have Spatial Analyst you should consider reading anyway, because it might help somewhere along the way.

If on the other hand, you do use Spatial Analyst, you might have noticed a disconnect between the Spatial Analyst Toolbox and the Toolbar.  Both contain pretty much the same tools, although their interfaces are different.  But when you set the options in the Spatial Analyst Toolbar (Analysis Mask, Cell Size, Extent, etc...), these settings do not carry over to the Spatial Analyst Toolbox.  This is because this information is contained in the Environment.  The Environment can be set universally by going to Tools --> Geoprocessing Tab --> Environments.

Start by adding a New Toolbox to ArcToolBox.  This is done by Right-Clicking on ArcToolbox and selecting New Toolbox

Your Toolbox will be given a generic name, and you can rename it.  Call it something like Tip.  Right-click on the Tip Toolbox, and select New --> Model.

ModelBuilder will open automatically.  To add a process to the model, simply drag the Tool from the Toolbox onto the model.  In my case I have dragged the Euclidean Distance tool found under Spatial Analyst Tools --> Distance.  It adds three items:  Euclidean Distance (the process), Output Distance (the raster output for distance), and Output Direction (the raster output for direction).  In this example, we are only interested in getting a distance surface.  Right-click on Output Distance and select Model Parameter (note: you might have to click on Output distance to select it before right-clicking).  Making this a Model Parameter means that you will be able to select the name of the output.  Now select Euclidean Distance, and right-click.  Choose Make Variable --> From Parameter --> Input Raster or Feature Source Data.  This makes a variable from this parameter so that the user of the model will be able to select the input.  You should have a new oval added to the model.  Select and right-click on this to turn it into a parameter.  Your model should look something like this:

 

Now deselect any of the circles or squares you might have selected, and right-click in the body of the model.  You should have an option for create variable.  Choose to make a Cell Size variable.  Add another variable, but this time choose Raster Layer.  Right-click on these two new ovals and turn them into Model Parameters.  Should look like this:


Next right-click in the body of the model and choose Model Properties.  Go to the environment tab, and open Raster Analysis Settings tree.  Add a check next to Cell Size and Mask:

Then click on the Values button to bring up the Environment Settings Dialog.  Click the double-arrows next to Raster Analysis Settings to expand it.  Then set the values to equal the variables you created:

Save your model and close.  Now you have a more robust tool that lets you set the parameters of the tool and the environment settings so that you can mask your output raster.