Model Builder Exercises
Model Builder Exercises
This exercise was written by Lyna Wiggins at Rutgers University in May 2008.
Our first model is for the classic notification work flow. This work flow arises when
you have to notify adjacent property owners about a potential variance, permit, regulatory
action, etc. We will be using a parcel dataset from Middlesex Boro. This is a shapefile,
and the pathname is c:\student\MiddlesexBoro\parcels.
Here is the pseudo code for our first model:
We want the user to be able to select any parcel, using a standard SQL query.
Next, we want the user to be able to specify the buffer distance to be used from the
selected parcel.
The buffer should then be generated.
We want the user to have an output map that shows just the parcels that need to
be notified.
Finally, we want to output a table of the parcels that need to be notified. (This
allows us to use the records in the output table for mailing notices to the correct
parcels.)
Step 1: Start a new model. Our first step is to create a new toolbox, start a new model.
To do this, open ArcToolbox. Right-click and select New Toolbox. Name it
<YourName>s Models. Then right-click on your new toolbox, and go to New, then
select Model. Name your model Notification using Rename.
Step 2: Add an input data set. Our next step is to open up the ModelBuilder window
and add our input data set. Open the ModelBuilder window by a right-click on the
Notification model, then select Edit. Bring in the parcel shapefile into ArcMap. Dragand-drop the parcel shapefile into the ModelBuilder window. Rename the parcel input to
Middlesex Boro parcels.
Step 3: Add a process to the model. Next, we want to add our first process the Select
tool. You are accustomed to running this tool from ArcMap. Here we need to find it in
ArcToolbox. It is in under Analysis, then Extract. Drag-and-drop it into the
ModelBuilder window. Use the Add Connection tool to connect the input dataset
(parcels) to the Select process. Then rename the output to be Selected Parcel. Our model
appears ready to run but, remember that we want to be able to select a specific parcel
from its address. So we need to make a variable from a parameter.
Step 4: Make a variable from a parameter. To make a variable from a parameter, rightclick on the Select process. Go to Make Variable, then From Parameter, then Expression.
Double-click on Expression and you get the usual SQL dialog box. Complete the
expression to select the parcel with an address of 421 Clinton Av. The field name is
PropertyLo. When you have completed your query statement, right-click on the
Model Builder Exercises, May 2008 page 1
Expression oval and select Model Parameter. Then rename the expression to be Query a
parcel address. We want to see the parcel that is selected as layer in our Table of
Contents. So right-click on the Selected parcel output and select Add to Display.
Step 5: Run the model for the first task. Use the Auto Layout and Full Extent tools to
organize your flow chart. The first task of our notification work flow is ready to run.
Click on the Run tool. The icon looks like this
. Check to see that the model
executed correctly by checking your Table of Contents for the selected parcel. At this
point, my model looks like this:
Step 6: Add the Buffer process. Now we want to buffer the selected parcel polygon.
Drag-and-drop the buffer tool from ArcToolbox. It is in Analysis, then Proximity.
Review the steps, above, to create a variable for a parameter so that the user can input the
buffer distance. Enter a buffer distance of 500 feet. Rename the parameter to Buffer
distance input. Rename the output to be Notification buffer. Dont forget to add this
intermediate data product to your ArcMap Table of Contents by a right-click and
selecting Add to Display. Run your model and check your output. At this point, my
model looks like this:
Step 7: Add the Clip process. Since our work flow indicated that we wanted to be able
to map the buffers that need notification, we want to add a clip function. Remember the
dialog window for the Clip tool. You need to first specify the input features. Your input
features are the parcels. Use the Add Connection tool to connect Middlesex Boro parcels
to the Clip process. You next need to specify the clip features. This is the Buffer for the
selected parcel. Use the Add Connection tool to connect Buffer to the Clip process.
Rename the output to be Parcels to Notify. Make sure to Add to Display. Run your
model and check your output to make sure it ran correctly. At this point, my model looks
like this:
Step 8: Create a table for a mailing list. Our final step is to create a table that we can
use to mail out the notifications. In the Data Management Toolbox, under Tables, you
will find a Copy Row tool. This tool works well here. Drag-and-drop it into your model.
Rename the output to be Notification table. Because .dbf files are particular about their
file names, it is smart to change its output file name. Double click on Notification Table.
Rename the output file to be Notices.dbf. And turn the check for Intermediate to off. For
the output, select Add to Display so that we can check our results. Close your
ModelBuilder window and dont forget to Save your model! Then close ArcMap,
saving your .mxd file. Here is my final model:
Assignment 1.1: We have been renaming the components of our model. This gives
more clarity to the model flow diagram. But what are the file names and paths to our
intermediate and final outputs? List them here.
Step 9: Rerunning the model. Rerun your model, changing the address to select to 1
Elmwood Av and your buffer distance to 200 feet. You will also need to change the file
names of your inputs/outputs to the processes. Remember that ArcMap gets unhappy
when you write to files with the same names. I always just add an incremental number to
the end of my file names to help myself keep things straight. Well talk more about this
file naming issue in a later exercise.
Step 1: Explore the data. Bring in all 5 datasets into ArcMap and do a bit of exploration
to start.
Step 2: Create a variable, and declare it to be a list. We could do a simple model like
the one following. But this is not an elegant solution! And it would be painful if there
were 20 (or more!) feature classes to be clipped.
Instead, we will create an iteration using lists. Create a new model in your own Toolbox
and name it ClipStudyAreas. Open up the ModelBuilder window for Editing. Right-click
and select Create Variable. Examine your choices here there are a lot. Then select
Feature Class. Right-click on your new Feature Class and go to Properties. Here you
want to click on the radio button for A List of Values. While you are there, note that on
the Data Type tab, it correctly specifies Feature Class. Note that there is also a Layer
Symbology tab. Here you could import a layer file to create a desired symbology. Click
OK. Note that you now have several ovals stacked on top of each other. This indicates a
List of Values will be input into our model.
Rename your Feature Class inputs to be InputFeatureClasses.
Step 3: The Batch Grid. But something is different here! Double clip on the
InputFeatureClasses oval. Instead of the usual parameter control dialog we are used to,
we get a Batch Grid. The user interface to this Batch Grid behaves somewhat strangely.
Rather than me trying to write about it, experiment on your own until you figure out how
it works. Here is my batch grid after I have specified the paths to the 3 input feature
classes:
Step 4: Create a Series variable. A Series is similar to a List in that it contains multiple
values. Where the Series is different, is that that the entire model will be run once for
each value in the Series. So we want our feature classes for multiple study areas to be a
Series. Then the Clip process will run on each of the input feature classes, once for each
study area. At this point, stop a minute, and think carefully about what this means for the
names of the output feature classes. We need to define these carefully so that we dont
use the same output file names! We will use a syntax convention to take care of this
issue. We will complete this in a later step.
Right-click somewhere in your ModelBuilder window. Select Create Variable. Again
select Feature Class as the variable data type. Rename your new variable
StudyAreaInputs. Then right-click and go to its Properties. Here, you want to use the
radio button to select A series of values. Click OK. Then double-click on
StudyAreaInputs, and fill out the Batch Grid correctly, using the two study area feature
classes.
Step 5: Adding the Clip process. Remember that the clip process first wants a parameter
for the input features. Then it wants a parameter for the clip features. Add the Clip
process to your model. Add a connection first from InputFeatureClasses. Then add the
connection from StudyAreaInputs.
.
Model Builder Exercises, May 2008 page 8
Step 6: The output file names. Finally, we need to deal with those output file names.
Double-click on the output oval. We will have to type in changes to the output file names
ourselves. ModelBuilder will not do this for us. For the first output, you should see the
pathname:
C:\student\Hunterdon\Hunterdon.gdb\roads_Clip.
Change this to:
C:\student\Hunterdon\Hunterdon.gdb\roads_Clip_%i%_%n%
The %n% syntax will have values of 0 and 1. The 0 corresponds to the first Series input.
In our case this is StudyArea1. The 1 corresponds to the second Series input. In our case
this is StudyArea2. This syntax will work for any n Series inputs. So you could create a
model for 20 (or any n) study areas this way.
The %i% syntax will have values of 0, 1 and 2. This corresponds to the Iteration on the
input feature classes roads, streams and wetlands. Roads will have value 0, streams
will have value 1 and wetlands will have value 2.
Complete the required file name changes in the output Batch Grid.
Then remember to select Add to Display so that the output feature classes will show up in
ArcMap for you to check.
Step 7: Set the models iteration value. We have 1 more step to complete before we run
the model. In ArcToolbox, right-click on the ClipStudyArea model, and go to Properties.
Open the Iteration tab. Here you will find a radio button that allows you to select Run
the model the following number of times. Here we want to override that value by
selecting Get the iteration count from this variable. You want to select
StudyAreaInputs as the variable. Now you can run your model. My model looks like
this:
Assignment 2.1. What are the names of your output feature classes?
We need to bring in a dataset for the census tracts in New Jersey, with a
population count field.
Then we want the user to be able to select a particular tract.
Then we will want to find out how many contiguous tracts we have to add to the
selected tract until the population count exceeds 50,000.
We would then like to map our result.
Step 1: Explore the data. Bring in the dataset for Census 2000 for New Jersey tracts.
The pathname is c:\student\CensusTracts\centrt2000.shp. The population count field is
named Pop2000. Try several thematic maps looking at both population counts and
population density (per square mile). Check out the tracts that are largest and smallest by
population count.
Step 2: Select a tract to start. Create a new model in your own Toolbox, and name it
CensusCounts. Bring in the centrt2000 shapefile. You should be able to add the Select
tool and complete the first part of the model, following the steps from Exercise 1.
Step 3: Select by location. Now we need to select by location. You know how to do that
in ArcMap, but where it the tool in Toolbox? It is under Data Management, then Select
Layer by Location. Make sure you fill out the parameters correctly for this model! Ill
let you figure this out for yourself. (But be sure to make the correct decision for
Selection Type!)
Step 4: Determining the Total Population Count for the selected polygons. Again, you
know where the Summary Statistics tool is in ArcMap, but where is it in Toolbox? This
time, find it yourself. The Summary Statistics process will output a table with a single
record (row). You want the output field to be the total population count. It is
automatically named SUM_POP200. (Notice the automatic shortening of the field name
for the .dbf file format.) Since this is a .dbf file, make sure that your output file name is
short!
Step 5: Checking to see if the total population exceeds 50000 yet. The Make Table
View tool (look in the Data Management Toolbox to find it) allows you to create an
Model Builder Exercises, May 2008 page 11
expression that selects all records that meet a specific criteria. Add this process to your
model. Fill out the parameters correctly. Since this is a .dbf file output, again check to
make sure your file name is short.
Step 6: Using a Boolean condition to stop iteration. Using the Get Count process
provides one way of setting a Boolean condition. Get Count returns the number of
selected rows from an input table. The output is of data type LONG, not a binary 0,1.
But it will work since the Boolean condition accepts any number greater than 0 as True.
Add this process to your model and set your parameters correctly.
Step 7: Set the Models Iteration. Back in ArcToolbox, set the iteration properties of
your model. See if you can figure this out yourself. (Hint: You might want to set the
maximum number of iterations as well.)
Check out the reading and powerpoint slides for the formula for translating rankings into
weights.) Remember how easy it is to confuse file names as you create all of the output
grids, so organize yourself right away with some naming conventions on your Draft
Model Flow Chart.
Step 2: Data Acquisition. Your first step is to acquire and organize the datasets for your
suitability analysis. Organize a file folder for your datasets where you have write access
and a lot of space. We will use existing datasets from the New Jersey Department of
Environmental Protection. Go to the NJDEP GIS site (http://www.nj.gov/dep/gis/).
Download the following datasets:
Land use and land cover datasets for 2002 for Watershed Management Areas 8
and 11.
10-meter DEM datasets for Watershed Management Areas 8 and 11
Known Contaminated Sites (statewide)
Natural Heritage Priority Sites (statewide)
Municipal boundaries (statewide)
Step 2: Data Pre-Processing. You need to pre-process some of your vector datasets
prior to rasterization. Complete the following tasks:
a)
Create a vector layer that is a single polygon for the Delaware Township
boundaries.
b)
Create a vector layer that is a single polygon for Delaware Township plus
a 1-mile buffer around the Township boundary. This will be your analysis
area. (Note: It is good practice to buffer around your actual study area
when using raster analysis to minimize the edge effects of some of your
analysis functions.
c)
Merge the 2 datasets for Land Use and Land Cover (LULC) for the 2
watersheds. (Note: You need these to be in 1 layer before rasterization.)
Then clip the merged datasets by your analysis area polygon.
d)
Mosaic the 2 datasets for elevation. (Hint: Use the Raster Calculator and
the following expression: MOSAIC (grid1, grid2).)
e)
Clip the Known Contaminated Site dataset and the Natural Heritage
Priority Sites dataset by your analysis area polygon.
f)
Before proceeding, reread the Goal and Objective statements, above.
Revise your Draft Model, as needed. Then create several vector layers
from the LULC. Following are 2 examples. You will need to figure out
others on your own.
a. For the suitability analysis, you will assume that new development can
not take place in existing URBAN (land use category 1 at the first
level). (Yes, I know that redevelopment is possible, but we are
keeping it simple here.) So use Select by Attribute and then Data,
Export Data to create a vector layer for the urban polygons. (Hint:
Later, when you rasterize this layer, remember how useful a value of
NoData can be in later analyses.)
b. You will need a vector layer for existing high- and medium-density
residential for Goal 3, Objective 1. (Hint: You will need to use the
g)
land use categories at the third level for this query.) Use Select by
Attribute and then Data, Export Data to create a vector layer for these
polygons.
Complete the other vector layers that you need to pre-process for the other
Objectives. As you do this, jot down notes about your decisions and
processing steps for later documentation.
Step 4: Rasterization and Raster Analysis. Reread all of the Goals and Objectives one
more time and again revise your Draft Model, if necessary. At this point your Draft
should become a Final. Complete the rasterization of all of the vector layers you have
created. (Hint: Dont forget, as the first step, to use the Options from the Spatial Analyst
toolbar. Set your extents to your analysis area and the cell size to 50 feet. Make sure that
the pathname to your workspace is correct. Dont forget to save a map file (.mxd file)
with these settings and your layers if you are not completing this exercise in one work
session.)
Then complete the raster analysis steps. Following are 2 examples. You will need to
figure out others on your own. (Note: Also continue creating notes on the decisions you
make for each computation so that you can document your Model.)
a)
Use the Map Algebra calculator to create a grid for all slopes greater than
10 percent. (How will you assign utility values to this grid? You might
choose to Reclass the slopes greater than 10 percent to a value of 1. All
other cells would have a value of 9 for this factor. This is a decision to
create a binary (two-value) layer. Other decisions are possible.)
b)
Create a Distance grid (straight line) to the existing high- and mediumdensity residential cells. (How will you assign utility values to this grid?
How will you decide on the maximum distance to use? You might
choose to use an Equal Interval classification, then Reclass the values to 1
through 9. Or you may have reasons to use another classification.
Whatever you choose here, write down the documentation for your
decision.)
Step 5: Weighted Overlay. You are now ready to complete your weighted overlay.
Document your expert rationale for the weights you use to combine your SUAs into the 3
MUAs. Then complete the complex MUA from the 3 MUAs, using the citizen groups
rankings for the weights. Prepare a good looking map for your final results. Assume that
this map will be displayed at a public meeting. This map should use the Delaware
Township boundaries, not the study area boundaries. It should have the basic required
elements - title, legend, scale and north arrow. Also include a note about what the values
mean in the final map. (Or you could add words to your legend that make it clear.)
Step 6: Model Builder. You realize that you may be called upon to run different
scenarios with different weights. You decide to construct a simplified version of your
Model using Model Builder. Although you are aware that you could go all the way back
to your vector layers and start the Model Builder Flow Diagram there, we will not do that
for this exercise. Instead, start with your 7 SUAs (the 7 raster layers, after all processing
steps). These 7 raster layers will be your input data layers. Your Model Builder will
show only how the weighted overlay was performed. Here are the steps to begin your
work with Model Builder:
a)
In ArcCatalog, go to your working folder (where you have been
organizing your data). Right-click on the folder and create a New
Toolbox. Rename it something appropriate.
b)
Back in ArcToolbox, right-click at the top level of ArcToolbox and select
Add Toolbox. Give the pathname to your new Toolbox.
c)
Right-click on your new Toolbox and select New, then Model. You are
ready to start with Model Builder.
d)
It is easiest to construct your Model by dragging and dropping. Drag and
drop the raster layers into your Model. Then drag and drop the tools you
need from ArcToolbox. Create the appropriate connections. Use Model,
then Run to execute your model.
Assignment:
Please turn in the following results, in a Word document:
a)
Your final suitability map, from Step 5. Along with your map, please
write a short description that describes the spatial pattern of the most
suitable areas for new residential development. In your description, also
provide the total acreage of the most suitable areas. You might also
suggest whether there is sufficient suitable area to support future growth,
and whether some of the Objectives are in conflict with each other.
b)
Document each of your SUAs. Include a brief description of the data
source, the pre-processing steps, and the raster analysis steps. Then
document how you assigned utility values for your 1 to 9 scales.
c)
Document the expert assignment of weights. Document the calculation
of the weights for the final complex MUA.
d)
Include your final Flow Diagram from Model Builder. If your input raster
layers do not have clear names (for someone other than yourself), please
define the names in your documentation.