- [Instructor] In this lecture, we'll walk through
demonstrations of different kinds of models
you can construct using Model Builder and ArcGIS Pro.
We'll start with a simple model,
expand that to include some parameter values
and then take a look at two different examples
of how we can incorporate iterators
into a geoprocessing workflow.
In the first example, we'll look at recreation sites
and Winooski River Basin.
We'll use the calculate field, select by location,
buffer, union and summarize geoprocessing operations
to create a table
with the total area of Winooski River Basin
covered by a recreation buffer.
Let's get started.
Here we are in the ArcGIS interface.
I'm got my recreation sites symbolized as green dots
and the Winooski River Basin
symbolized with an orange outline.
If I look at the attribute table
for the recreation sites data set,
we see some attributes we've worked with before,
acreage and the various summer and winter parking spaces.
I also wanna point out two other attributes
that I've created.
The first is recreation site.
These are all coded with the value of one.
Of course it makes sense that a recreation site point
is a recreation site.
So the point is not to use this here now
but remember that when you buffer and union data,
that the attributes are carried over.
So in the end stages of our example here,
when we want to summarize the amount of area
within the Winooski River Basin,
that's covered by a recreation site buffer,
we'll need this value of one
to be able to make the proper selection.
The other attribute of note here
is the buffer distance.
Right now, these are all coded as zero.
Over on the Winooski River Basin data set,
one other attribute to point out is WRB.
Again, this will serve that same function
as the Is Recreation Site that I just described.
Let's create our model.
From the Analysis ribbon, I click Model Builder
to open up a new blank model interface.
The first order of operations here
is to calculate a field.
I can search from the Tool dropdown
and add Calculate Field to my interface.
Okay, I added the rest of the geoprocessing tools
that we'll use in our model.
Select Layer by Location, Buffer, Union
and Summary Statistics.
Now, let's add some data.
I'm gonna use the Winooski River Basin
as part of my union operation
and the rest of the model will be driven
by the recreation sites.
So we see we've added two data variables into the model.
Now let's begin to set the model up.
I drag a connector from my recreation sites
to calculate field
'cause the first thing I want to do
is calculate the value of the buffer distance.
My recreation sites will serve as the input table
in the field calculation.
If I double click Calculate Field,
we see a familiar looking dialog box.
We're going to use our buffer distance as the field
and we'll multiply the number of summer parking spots
by five to calculate the buffer.
Note that when I click okay here,
I'm not actually making that calculation.
I'm just setting up the tool parameters
to be included in the model.
I click Okay and notice that now this portion of the model
is ready to run.
Okay, well the next step here
is that I wanna select all of the recreation sites
that are within the Winooski River Basin.
So I drag that connector
and specify that's an input feature.
My Winooski River Basin is going to be the selecting feature
This way, I only select those recreation sites
within the Winooski River Basin for the buffer operation.
This just saves time later on.
Now that we've selected our features,
we can use those as the input for the buffer operation.
Specify the input features
and then I just need to also indicate
that we're using a field
and that that field is the buffer distance value
we just calculated before.
Let's also be sure to dissolve all those features
into a single feature.
Okay, now we've got our buffer output
and that's going to be one part of the union.
Specify those recreation sites
and my Winooski River Basin as my two input features.
Now, with my output from the union operation,
that will serve as my input for the summary statistics
and I double click to open the Summary Statistics Dialog box
So we just need to specify
the summary statistics we want to calculate
and whether or not there's a case field.
When I open up the Field Options here,
we know that we wanna sum the shape area in this case
but I see two different versions represented here.
Since I can't tell which comes from which source,
I'll just calculate both
and we'll see what happens.
That should make it easier to identify the correct one
and we can fix the model later.
Now remember those Is Recreation Site and Is WRB attributes
that I described before,
those are gonna be our case variables.
This way any of that buffered area that falls outside
of the Winooski River Basin will not be selected
and any of the areas inside the Winooski River Basin
that are not covered by a recreation site
will also be able to be selected
from the rest of the records.
Okay, at this point, our model's complete.
I click the check mark to validate.
Probably a good idea to save at this point
since we've made a lot of changes
and from here I can run.
Well, looks like I creates us a problem here.
Got an error message that caused the model to fail
indicating that there's an invalid case field name
in my Summary Statistics operation.
Let's try to take a look at what that might actually mean
and how we can fix it.
First thing I'll do is look at my Union data set.
It's already been added to the display here
and if I look at that attribute table,
maybe we'll get some insight as to what's going on.
We see in the attribute table
that the Is WRB attribute is there
but the Is Recreation Sites attribute is not.
It must have been dropped out earlier in the geoprocessing.
So let's come back to our buffer output
which is the previous step and look at that attribute table.
Sure enough, it doesn't appear there.
I think I might have the Dissolve settings incorrect
in the buffer operation.
So let's take a look at that.
I set it to Dissolve All Output Features
into a single feature.
Instead, I meant to dissolve based on a listed field
and the field that I want is that Recreation Site.
Okay, let me validate the model,
save the model
and try to run it one more time.
Notice a bunch of the polygons, our points are skipped
because of a negative or very small distance
indicating that the buffer size was really small
in that location.
Looks like the model ran to completion.
Now, I can look at the Attribute Table,
the Summary Table sorry that I just derived
to get a better idea of the results.
Okay, well this clears up the sum shape area.
We obviously don't need the second one
to be included in that summary statistics calculation.
And what we can see here is that we've got one polygon
where both it's inside the Winooski River Basin
and it is a recreation site
and we can see that area here.
If we want to compute the percent
of the Winooski River Basin that was covered
by the buffered recreation sites,
we could simply refer back to the original
Winooski River Basin data
and divide the output value from this analysis
by that shape area from the Winooski River Basin.
We'll continue our example by extending the simple models
to include parameters
for both the Calculate Field expression
and the buffer distance.
Note that I've made a slight change
to the Recreation Sites Table.
Our buffer distance,
we'll refer to the summer buffer distance
and I've added another column to represent
the winter buffer distance.
We'll use the parameters to control
which buffer we're calculating the summer
or the winter buffer distance
as well as the buffer that's applied
to the recreation points that are selected.
We come back over to our model.
Again, we see its the same model that we had before.
I'm gonna clean it up a little bit
by clicking on the Auto Layout
which in turn means I need to expand the window a little bit
so I can see everything.
ArcGIS has simply organized the layout
according to the workflow I specified.
Okay, let's create a parameter
from our Calculate Field operation,
a variable from our parameter
and we're gonna use the expression
as what we want to specify for our parameter.
Now, the language gets a little bit confusing here
because the expression is a parameter
of the Calculate Field tool
but if we want the expression to also serve
as a parameter in the model that we're running,
we right click once again and check the parameter button.
You see the little P next to it,
that indicates that's something that you can set
at runtime to affect the way the model performs.
If we double click this,
we look and we see right now
that the expression is set to
number of summer parking spots times five.
That value's automatically assigned
to the summer parking buffer
that we specified earlier.
We can add one more parameter here
so that we can determine the field name
or the field that we're going to calculate.
Once again I'll set that as the parameter for the model
and if I double click,
I see that I now have access to a dropdown window
to indicate the different fields that I can update here.
Okay, one more parameter that we need to add here
and that's our buffer distance.
I'll set that as a model parameter
and if I double click, I see already that it's indicated
as a field which is what we want
and here are my list of options.
The winter buffer distance doesn't show right now
but it will once the data reloads into the model.
Okay, note that I validated and saved my model.
Now if I run from here,
the model will compute with the settings
that are already enabled,
the parameter settings I should say
that are already enabled
and produce my output.
But instead, let's run it from the Catalog
from within one of our tool boxes.
Actually not one of our tool boxes,
the tool box specific to this project
and if I double click that,
we see now that I've got some parameters
that I can set here.
Not in a very nice order
and I could fix that as well
if I want to get into updating the interface here.
But the field name pertains to the calculation
that's being made
and the distance value pertains to the buffer
that we're applying.
So, let's keep our summer buffer parking.
Instead of five let's set that to 25
and I'll click Run.
Another error message just to keep things interesting.
This one about a schema lock.
Think I might have to close this window here
for the attribute table.
Okay, let's try that one more time.
Note that it reverts to that value of five.
We've got our other attributes set already properly
so let's go ahead and click Run.
Model's running writing my summary statistics
and we get those same kinds of warnings
that we saw before.
Note that none of the data
is added to the interface this time.
That's okay.
We can come back into our Catalog,
refresh that geo database
and we have our Output Table right here.
Looks like I neglected to specify
a good output naming convention for that.
Note also that all of the intermediate data
has been deleted
so I no longer have that Select Later By Location Result,
that buffer result or the union that appears.
I could modify that so that the intermediate data
is not deleted
by checking this box here
which will affect the entire model
or I can manage data sets individually
if I wanted to keep them.
For now let's just be happy with letting those get deleted
as the successful conclusion of the model run.
Okay, so you can see now how pretty rapidly
you could run a number of different versions of this model,
each with their own buffer distance,
each with their own selection criteria
be it for summer or winter buffers that you're interested in
and rapidly calculate the amount of the watershed
that's affected.
Now, let's take it one step further
and look at some iterators in our next example.
In this next example, we're gonna change things up a bit.
We'll look at town boundaries and some invertebrates data
and we'll use the iterate feature selection Iterator
which is kind of like a select by attribute operation.
The output we're going to produce
will be an Invertebrates feature class for each town.
Now why would you maybe wanna do something like this?
Well, suppose that this information is confidential
and you don't wanna share it or distribute it too broadly
but town's only administrator might need this information
for making permit decisions based on whether there's
endangered invertebrate species in that location.
So, suppose you're working for the state
and you control this data set
and you want some easy and repeatable way
to accommodate these requests.
You could construct a model with an iterator
to cycle through the data as the request come in
and rapidly turn that request around.
I've already taken the liberty of constructing
the initial stage of the model here.
We're gonna use a Select Later by Location operation
and then copy those features that are selected
into a new output data set.
And of course if I run this now,
what will happen is that
all of the invertebrate point locations
located within my Central Vermont towns
will be selected and copied to a new output data set.
But that's not exactly what we want.
Instead, we wanna go town by town
through my list of towns here
and select only the invertebrates that are located
within that town boundaries.
In this case, we use the Iterate Feature Selection iterator
to make that happen.
If I click on the iterator dropdown,
I click that Iterate Feature Selection
from the list of options
and it appears in my screen.
Once again I'm going to expand my interface here
and maybe shrink the display size just a little bit.
So, now that I've got my iterator in,
it's time to populate that.
First things first,
since we're gonna iterate over the towns,
I'm gonna break my connection
to that Select Later by Location with the town data
and instead, I'm gonna connect my town
to my Iterate Feature Selection
and they will be my input features.
So, from here, I'm gonna just rename this
to make this a little bit easier for me to remember.
This is the town boundary,
the actual feature itself,
and this is the town name, the attribute
of the selected feature.
Okay, from here, I'll connect my town boundary
as the selecting features
in my Select Later by Location operation.
Let's clean up that window one more time
and see what we can see here.
Now, I've got my Central Vermont towns being iterated over
and for each one of those selections,
that information's passed to the town boundary
which is then used as the Select Later by Location,
the selecting layer,
to select the appropriate invertebrates point locations
that can then be copied into a new output feature class.
So we've got one last thing here to do.
Instead of naming every output feature class
Invertebrate Copy Features,
let's specify the town name
using inline variable substitution.
So again, that value town name comes from here
and when we want to do that inline variable substitution,
we surround that variable with percent signs.
Did I already say one last thing
because we have one more thing that we should do here
before we move on.
In this case, I'm gonna use this Group field
and my Town Name attribute
and specify that we should skip any null values.
Okay, at this point we can save and validate the model
before we click Run.
Here we are, the model has finished running
and we can scroll back through the model log
to find out if there are any problems.
So for example, for the town of Johnson,
we generated an empty output.
That means there are no invertebrate points
located within that particular town.
Likewise, we've got an error message here
that did not cause the model to fail
but means that the data for this particular town
was not written to output.
In this case, it's an issue with spaces in the filename.
Hyde Park has a space in the town name attribute.
If this was more important than just a demonstration,
I could go back in to the attribute table
for my Central Vermont town boundaries
and make adjustments to those town names.
In this last example,
we use the For iterator to create variable size buffers
based on the number of parking spaces in the winter
at each one of the recreation sites.
As you can see, I've already created most of the model here
and I've added the For iterator.
Everything's ready to go except for that iterator.
In this case, you see that you need to specify
a From value, a To value and the step size
or the increment between that From and To value.
Let's ago from 10 to 50
with a step size of 10.
I click Okay and now it appears
that everything's ready to run.
Let's check in on my Field Name.
I'm gonna make a calculation for that winter buffer distance
and in terms of my calculation,
I'm gonna multiply the number of winter parking spots
by the value that comes out of my iterator.
10, 20, 30, 40 or 50.
From there, I set my buffer
for the BufferDistanceWinter
and the last thing I need to do
is change my Output Feature Class name
so that I write a new feature class for each buffer size.
Once again I add that percent value percent
inline variable substitution and click Okay.
At this point, I can save, validate and run the model.
I'll join you in a minute when it's done.
Well, the model ran to completion
and we can see the outputs here
all in different shades of blue,
all representing the dissolved boundaries
around the buffered regions for our recreation sites
based on that winter parking space availability.
All right, well that's it for iterators
or at least that's all I'm gonna show for now.
There's plenty more to learn here like always
but I think it's time to let you get your hands dirty
and see what works for you
as you develop your own geoprocessing workflows.