- [Instructor] Hi, and welcome to module seven
of "Advanced Geographic Information Systems."
This week we'll have three lectures,
two "Slide Decks" and one live demo of
a model construction in ArcGIS."
Let's get started.
This first lecture, we'll focus on
the basics of model builder, the functionality with
an ArcGIS that allows us to specify
a geo processing workflow
using a visual programming environment.
A model is considered a collection of one,
or typically more geoprocessing tools connected
in a specific order to represent
that geoprocessing workflow.
We've got three things to consider
with our model variables.
First, variables are represented as data
or values that the user adds to the model.
Second, only the output variable
or the output data set produced by
a geoprocessing tool is created automatically.
The rest is up for the user to specify,
and then finally, to employ tool parameters
and variables in a model,
either create standalone variables
within the model itself,
and then connect them to a tool
or expose those tool parameters as variables
and then the user can specify
the proper parameters at runtime.
The tool element is one of
the basic building blocks of a geo processing workflow.
These elements perform various operations
on geographic or tabular data.
A tool dialogue is something
we've seen many times before.
It's the interface where a tool's parameters
are specified and much like
the geoprocessing operations
we've performed with individual tools,
those dialogue boxes will look very similar
within the model builder environment.
In terms of tool parameters,
we're talking about the inputs, outputs,
and the specifications that impact
the geo-processing that the tool performs.
Again, this is something we've worked
with in the past as well.
And then lastly, inline variable substitution.
This represents a variable that can be used
as a value or a data path for another model parameter.
We enclose these variables inside percent symbols,
and we can use inline variables substitution
for model variables,
system variables, or environment settings.
Now, once again, these geo processing tools
form the basic building blocks of a geoprocessing workflow.
There are three different options, a built-in tool.
Again, something we've worked with many times before.
These are the geoprocessing tools contained
in one of the many different ArcGIS toolboxes.
A script tool such as a Python file,
or if you'd like to go old school,
an AML file that's short for Arc-macro language,
or even an executable, a dot exe or a dot bat file
can be created using the script tool wizard
and then run from a file on the disc.
And then lastly, a model tool, in this case,
we're nesting models, one within another.
Now in terms of variables,
we've got data variables and value variables.
Data variables are model elements
that contain descriptive information
about data stored on the disk.
And in particular, we're referring here
to either input data or derived data.
And note the colors of the ovals here,
these are important to understand
the various components of the ArcGIS models.
Now value variables represent things like strings, numbers,
true false values, spatial references, and so on.
These do not reference data that are stored on the disk.
And these can be things like input values or derive values.
How do we link all those different pieces together?
We use model connectors to connect data
and values, to tools.
A data connector connects data
and value variables to tools and is symbolized
with a solid line and arrow.
An environment connector connects a variable containing
an environment setting to a tool,
so the tool will be employed
the environment setting what executed.
A pre-conditioned connector ensures
that a geoprocessing tool only be executed
after the contents of
the preconditioned variable are created.
This tool is represented with a dash arrow.
In this case, the dashes are much shorter.
And then lastly, there's a feedback connector
and this connects the output of a tool back
into the same tool as an input, otherwise known
as a feedback loop, and these connectors
are displayed using a dash line arrow format
with a cyan color.
In terms of the model process,
once again, the model itself is a tool
and the variables connected to it.
The connector lines indicate the sequence
of the processing order and not surprisingly derived data
from one process becomes the input data for another process.
And I should note that each process is
in one of four states, not ready to run,
ready to run, running, or has been run.
Let's look at the image over on the right
to clarify those different states.
Not ready to run values are symbolized simply
by a plain black outline with the polygon filled in white.
Once a tool is ready to run,
you'll see that those icons are filled in with
the assorted colors, you see in that ready to run column.
And when a tool is running,
either the tool or the iterator,
if there is one in your model, will flash red
to indicate the stage of the process the model is in.
And then lastly, once a tool has been run,
you'll notice that there's a shadow offset
to the lower right, indicating that tool iterator
or derived data derive value has been run or produced.
Now, there's really three different types
of data that we can think about, input data.
And we all know what that means.
These are the input data sets that we supply
to a geoprocessing tool so that
some geoprocessing operation can be performed on.
Intermediate data, represents data created
from each step of the model.
Now these can be data that you might want to keep,
or that you get rid of because you don't need them,
once the model has been run to completion.
So these are created as a middle step
to connect other processes that will create
or derive the final output, or perhaps
it's another intermediate step before you get
to that place of deriving the final output.
These data are deleted by default,
but, you can manage that data within the model itself,
specifying both the location, whether
or not it should be deleted, or even
whether you should add that to the final display
once the model has been completed.
And then the last of the three data types
are the output data.
These are the data sets that represent
the derived information from the model run.
Optionally, you can include iterators within your model,
an iterator repeats a process or
a set of processes on an input or a set of inputs.
ArcGIS includes 14 different types of iterators
to help implement geo processing workflows.
Of course, there's the typical four and wild loops
that any of you that have done any programming
would already know about,
but you can also iterate over specific data elements
from features and rows selections to specific file types
or entire workspaces collections
of data stored in a single location.
I recommend that you review the help here
for more information about each iterator type
and to help decide which iterator
might be most appropriate for the model
that you want to construct.
Now, when you create a new model,
you really have three different options.
You can, from the analysis ribbon,
click on model builder, from the catalog pane,
you can right click on a toolbox and specify that you want
to create a new model, or once you're already
in the model builder interface,
you can look on the model builder ribbon
and click the new button to create
a new model in that workspace.
Let's look at a couple example models here.
In our first model, we want to create
a geoprocessing workflow to select features
from a dataset, buffer those selected features,
and then clip those buffered features
to the extent of a watershed.
For our input data,
we've got our recreation sites,
point data representing recreation sites
in Vermont, and the watershed boundary
for the Winooski River Basin.
We'll use a select layer by attribute, buffer,
and clip geoprocessing operations
as part of our model.
Initially, we'll specify a selection expression that says
that we want to select all of the recreation sites
with more than 25 summer parking spaces.
And we'll buffer those with a 750 meter distance.
So here's what it looks like
when you have your blank model, again,
blank slate here up to you,
what you want to do next.
Let's add our select layer by attribute.
And in this case, I've opened
my geoprocessing window and I'm searching
for that tool within that geoprocessing interface,
like we've done so many times before.
From here, simply drag and drop the Select Layer
by Attribute tool into the interface,
and we see that we now have
our first geoprocessing tool added
to the model and that it state is not ready to run.
Let's add a couple more.
From the model builder ribbon,
there's also a tool, search menu.
Click that drop-down, type buffer, or at least begin
to type buffer to identify potential options there.
Then I'll drag that buffer operation into the window,
as well as the clip operation.
Again, those three represent
the geoprocessing options that we want
to pursue with our model.
Next up, we need to add some data.
Once again, you can do this from multiple places,
the contents pane or the catalog pane
are the two most likely options.
Simply drag and drop your data into the model.
And you see now that we've added both
our recreation sites and
our Winooski River Basin boundary to the model.
From here, we need to start establishing connections
to the different tools in the geoprocessing workflow.
Drag an arrow from recreation sites to select layer
by attribute, and then specify what role
that data set will play in the geoprocessing operation.
In this case, our recreation sites represent the input rows.
Once that connection has been established,
we see now that the select layer
by attribute tool is ready to run.
That's not totally accurate.
It's only mostly ready to run since we still need
to specify an expression.
If I double click on select layer by attribute,
we should see an interface that looks relatively familiar.
We've used the select layer
by attribute many times before.
In this case, I specify an expression,
the number of summer parking spots
is greater than 25 and click okay.
Now I know that I've produced a recreation sites
dataset temporary one or intermediate data based
on that expression, selecting all of
the recreation sites where there's more
than 25 summer parking spots.
You can click the auto layout to have ArcGIS organize
the model in the window for you.
It's definitely easier to do it this way than
to try to move all those individual pieces around.
Again, I've taken a few liberties here.
I've specified my buffer distance
and indicated that my Winooski River Basin
will serve as the clip feature for the model.
I can also choose to keep or delete the intermediate data.
Remember, intermediate data is deleted by default.
Once I click run on the model builder ribbon,
I see a window popup that informs me
of the stage of processing.
Here, I can see that I'm on the second
of my three geoprocessing steps
and that that buffer is working.
Once the model is complete,
I can choose to add my output data
to the display, by right clicking on
that green oval that represents the output dataset
and clicking add to display.
I can see the results here on the left-hand side.
I've got all my input data and we can see
all of those different recreation sites
that have more than 25 summer parking spaces,
because they're still selected and rendered
in that cyan pigment.
On the right-hand side,
I've zoomed in on a portion
of the Winooski River Basin,
and we can see not only the buffers
for those recreation sites that meet
that 25 summer parking spots threshold,
but also that those buffered regions along
the edge of the Winooski River Basin
get clipped to its boundary.
Okay, let's take it one step further.
If I right click on my select layer by attributes,
I can specify that I want
to create a variable from a parameter,
and in this case, from that tool parameter,
the expression, remember that was
the number of summer parking spots greater than 25.
Once I do that, we see
an expression added to the interface.
And if I double click that expression,
I can specify whatever I want.
Let's stick with the 25 summer parking spaces for now.
If I right click on that expression variable,
I can choose to set that as a model parameter.
And once I do that, we see a little p up here
next to that particular variable.
When I run my model from within the toolbox,
so in this case,
I'm running demo underscore model one,
we see that a dialog box pops up.
We've only specified a single variable parameter here,
and that was that expression.
But you might imagine that you could have
a lot of different parameters
that need to be specified,
potentially even multiple different expressions.
And if you leave your variable name
as expression, that might prove confusing
for some other user.
Instead, let's rename our expression
to recreation site selector.
And now when I run that model from my toolbox,
I see recreation site selector, and that prompts me
to specify a correct query for whatever attribute
I'm interested in selecting out of the whole dataset.
Okay, let's take a look at one more example here.
In this case, we want to create
a geoprocessing workflow to select a feature
from a dataset and clip the features of another dataset
to the extent of the selected feature.
Our input data for this example includes, invertebrates,
the invertebrate populations in Vermont,
as well as town boundaries for Vermont.
For geoprocessing tools,
once again, use select layer by attribute and clip.
But this time we don't have a selection expression
or a specified output feature class name.
Instead, we want to use an iterator
and inline variable substitution to specify both
the selection expression and the output feature class.
Then we'll use that iterator to provide the town name,
to serve that function.
I've already built the model out here
and you see that I'm using my town boundaries
as the input to the iterate feature selection.
And that from that, I'm using the clip function
to clip my invertebrate populations down
to individual town boundaries.
Note that the iterate feature selection
iterator produces two outputs.
One is the selected feature, the actual town boundary,
and the other is the value,
the name of the town.
It's important to note the difference
between the two, because we'll use
those differently in the model.
One other thing I should specify
here before moving on.
Note my output data set here,
invertebrate communities, percent TownName percent.
That's the inline variable substitution piece
where that TownName, that percent TownName percent value
comes from the TownName output from my iterator.
This way, I know that each one
of my output data sets will have a unique name.
As I'm running the model, I noticed slight issue.
There's an error message here that indicates
that a particular geoprocessing step failed
to execute because the parameters are not valid.
On closer inspection,
I see that that's because the town name includes a space.
In this case for Averys Gore and spaces
are not allowed in a file name.
Now this does not cause the model to stop running.
It simply skips over this town
in the list of processing operations.
If this was something more than a demonstration,
I'd go back in and make adjustments
to my town names to ensure
that my model can run smoothly.
One other thing to note here is
that I also have some warnings
in that pop-up window that I see indicating
that some of my outputs are empty.
This indicates a town that does not include
any of those invertebrate populations,
nothing to worry about here,
we can simply let the model continue to run.
Lastly, if we look over in the output database
where I've chosen to write all of my output data sets,
I can see separate feature classes for each
of the different town boundaries.
Invertebrate clip is the prefix
and the town name is the suffix.
Again, drawn on that information
from the iterator and using
that inline variable substitution approach.
Okay, well, that's enough for slides.
In the next lecture, let's take a look
at a live demonstration of how we might work
with model builder using ArcGIS Pro.
I'll see you in a couple of minutes.