- [Brian] The second half of the Module Three lectures,
we'll look at methods for summarizing vector
or raster data in one dataset
that fall within boundaries defined by another dataset.
You're probably scratching your head
wondering what I mean by that.
We've seen examples of this before
but not on this level of detail.
We'll look at both vector and raster approaches
to summarizing data
to resolving a common problem in spatial analysis.
You've got two different datasets with different boundaries
or different geometries or even different data models.
And you want to know how much of one
is contained by the other
or how much of each type of one
is contained by each boundary of the other.
Still not making sense?
Well, that's on me.
Let's try looking at some pictures
to see if that will clear anything up.
Let's start by talking about vector data.
Summarizing the values of one vector dataset
within the bounds of another vector dataset.
We'll look at the polygons inside polygon scenario first.
Look at the scenario on the left.
You have a single bounding polygon in green
and a single summary polygon in blue
that is fully contained inside the bounding polygon.
That's about as simple as it gets.
You could look at the attribute tables of each
and determine what the percentage was
or you could look at the attribute table of your blue circle
and determine the area of that one polygon
and equate that to the area of the summary feature
within the boundary feature.
What about the less symbol cases
like the two we see in the images on the right
where either the polygon you're trying to summarize.
the blue one,
is not fully contained by the bounding polygon
or what if you're dealing with multiple boundaries
and multiple input polygons?
In this case, you have a few different options
at least partially guided
by your preferred geo-processing workflow.
From the overlay toolkit, you could use tools like union,
intersect or a portion polygon among others.
Alternatively, you could look in the Summarize Data toolkit
to find Summarize Within or Summarize Nearby as options.
I highlighted my personal preferences in yellow
but don't let that limit what you try.
I've been doing some of these tasks the same way
since I learned how to perform geospatial analysis
and some habits are hard to break.
What about summarizing line features
within polygon boundaries?
Once again, we have the simple case over on the left
where a single line feature is fully contained
within our single polygon.
Scan right to see similar scenarios to the last slide.
What are our options here?
All the same as before?
Not in this case.
Remember, the Union tool requires polygon input datasets.
So it's not applicable here.
Intersect and spatial joint are still available to you
but do proceed with caution if you're pursuing a ladder
as your preferred approach.
The last are a possible three combinations
is summarizing points within polygons.
Once again, we have the simple case
over on the left-hand side.
A point is either inside a boundary
or it's outside a boundary.
Those are the only two options.
It's sort of a tie goes to the runner type situation.
Assuming that you don't have too many features,
a visual assessment might get the job done.
But I'd probably still rely on the computer
to get the count right.
And once again, we see the same list of options
available to us
if we were analyzing lines within polygons.
Let's get to some specific examples.
We'll look at a couple of different approaches
to get to the same endpoint.
The examples will use trail buffers and town boundaries
as input datasets
and we'll compute how much of a town
is comprised of a trail buffer
before expanding the problem to compute how much of a town
is of a particular kind of trail buffer.
We'll start by looking at the union geo-processing tool.
On the left hand side, we see the data we're working with
for this example.
In green, we've got buffered areas around trails
and the gray with black outlines,
we've got our town boundary units
within the Mud River Valley.
We want to calculate how much of each town
is comprised of this 500 meter trail buffer,
the green polygons.
Before we get back to the Union tool,
I'll highlight one technique that I like to use
to keep track of my data
when combining multiple datasets
using an overlay operation.
I include a variable that describes the dataset.
So, for example, I created an attribute named IsTrailBuffer
set a data type of short
since it will only contain values of zero and one.
And then I assign all the buffer polygons
a value of one for this attribute.
Remember, the Union tool combines all of the attributes
of your input datasets
and writes them to your output dataset.
This makes it a bit easier to track
where specific data come from in the composite dataset
while also preserving those values to be used later
to identify specific features of the new dataset.
Once I performed the Union operation,
again using the trails buffer and the town boundaries
as my inputs,
a new output feature class is produced
and we can see that on the left side of the slide.
The Union tool has broken down those polygons
into multiple smaller polygons
based on where they fell in relation to the other polygons
of the input data.
Let's look at the attribute table
of the town boundary dataset
and the output of the Union operation.
Town boundaries table is on top.
Notice that it includes that six digit FIPs code
that is unique to each town.
That's important because it means we can join the output
to the original boundary dataset.
We see seven records in the output feature class
in the bottom table
and note that the FIPs code is present here as well.
If I were to use Select By attributes to select the polygons
with an IsTrailBuffer value of one,
notice that includes features which extend
beyond the boundary of the three Mud River Valley towns.
If I look at the attribute table for that selection,
I see something interesting.
Of course the selected records all have
an IsTrailBuffer value of one,
that was the expression we evaluated
using Select By attributes.
Instead, look at the FIPs six code
or the FID for the Mud River Valley town.
The FIPs code equals zero
for that same record that the FID code equals negative one.
Those are the polygons that fall
outside of the town boundaries.
If I revise my Select By attribute expression
to include a trail buffer value of one
and a FIPs code not equal to zero,
I select fewer records.
Only those polygons within the town boundaries
that are also trail buffers.
From here, you can export just the table.
We've used the Export features tool
to create a new feature class many times before.
This time, we're only going to export the table
because we're going to use it in the next step
to join back to our boundary data,
the Mud River Valley towns.
Once I select Export Table from the list of options,
an interface that should look familiar will open.
It looks pretty much the same
as the Export features dialog box.
If I expand the field section
of the Export Table dialog box,
you see a list of all the fields that will be written
to the output table,
not shown in the image in the center.
Over on the right,
we can see that I've narrowed that down a bit.
I bleated fields from the list by hovering over them
and clicking the red X that appears.
Remember, you're not deleting the attributes
from the input dataset.
Rather, you're excluding them from being written
to the output dataset.
Let's make one more adjustment
before completing our export operation.
I switched over to the Properties tab
in the image on the right.
Here I can change the name of the shape area attribute
to something more descriptive
to make it easier to keep track of.
In this case, I'll rename the attribute buffer area
so I know exactly what it represents.
Then once the table's been exported,
we can join it to the original boundary dataset,
the Mud River Valley towns.
we use the FIP six code to do that.
Afterwards, as you can see on the left,
you can use that information to create a core plus map
to symbolize the total area of trail buffers in each town.
If you want to calculate the percent of the area,
create a new attribute, set it to type double
and divide the buffer area by the shape area value
for each town.
Okay, so that was the union approach.
Let's check out Summarize Within
to evaluate how that works in comparison.
Once again, we've got the same input data,
green trail buffers and gray town boundaries.
Look at the tool dialog box on the right.
I set the input polygons to the town boundaries
and the summary features
which I think should be called features to summarize
or the trail buffer polygons.
Assign an output feature class name
and specify which fields you want
the summary statistics to be calculated for.
Once again, we want to compute the sum of the shape area
of the trail buffer polygons within each town.
Click Run to produce the output dataset.
The output feature class attribute table
is displayed on the top right of the slide.
And I include the output table
from the union operation below for comparison.
In short, we've accomplished in a single step
what required multiple steps or geo-processing operations
when we started our journey with the Union tool.
I'll also note that there's slight variations
in the values that you see between the two tables.
This reflects different data processing subtleties
between the Union and Summarize Within
geo-processing operations.
Let's look at one more example.
In the last example,
the trail buffer data had a single value.
One, meaning that all the polygons in the dataset
were trail buffers and nothing else.
In this case, let's change up the data a bit.
The revised version of the data still features trail buffers
with its trail buffer value of one.
It also includes polygons that are not trail buffers
and assigns a value of zero to that same attribute.
I set the same parameter values
for the Summarize Within tool as the last time around.
But this time I use the modified trail buffer data
as the summary dataset.
Let's take a look at the output.
Think this is going to work?
The top table represents our first effort
for Summarize Within.
Remember that was the version that only included
the trail buffers and nothing else.
Note the difference between the summarized area
and the shape area values in that top table.
The summarized areas are all smaller than the area
of the town.
If you look at the bottom table,
you see something very different.
In this case, the summarize area is essentially the same
as the area of the town.
Why might that be?
Think back to that input dataset.
Remember that each town was entirely covered
by the modified trail buffer,
taking on a value of zero, not a buffer
or one is a buffer.
We've asked ArcGIS to summarize those polygons
and not surprisingly as a result,
the summarized values match the area of the town.
This is obviously not correct
and not the result that we were looking for.
Let's try a different approach.
I've modified the data again here to represent the 500 meter
and 1000 meter buffer around the trails in the valley.
In this case, we'll use a group field
to help make better sense of the outputs.
This is the same basic idea as a case field
that we've seen used before
once summarizing the values in a table.
I set up the Summarize Within in the exact same way
in terms of summarizing the shape areas
of the trail buffer polygons.
I'll use the buffer distance as the group field
so I can distinguish those values in the output table.
Lastly, we also need to specify an output group table name
to write additional outputs too.
We'll see what that table represents here in a minute.
Let's look at two tables here.
On the top is the attribute table for my buffer polygons.
The total area of all buffers is shown on the table.
Next, look at the table below.
This is the Summarize Within result.
Note that the value is smaller than the one above. Why?
Remember, some of those buffer polygons
extend beyond the town boundaries.
The difference in those two values
represents the amount of trail buffer polygons
outside of the Mud River Valley.
Two of the things to note about the Summarize Within result.
The table includes a total area
of features that were summarized.
and there's an attribute named JOIN ID
on the right hand side.
Based on its name, I think you can probably figure out
what that's going to be used for.
This slide features the Summarize Within result
on the top left.
This is the same table from the bottom right
of the last slide.
The output group table, that was the other output you needed
to specify a name for in the Summarize Within dialog box
is shown on the bottom right of this slide.
What's going on here?
Notice the JOIN ID and buffer distance columns are included.
On closer inspection,
and notice there are repeat values
for each of the JOIN IDs;
one for the 500 meter buffer,
the other for the 1000 meter buffer.
This will make it difficult to join the output table
to the boundary dataset
like we tend to do after performing summary operations.
One approach here is to derive what's known as a pivot table
A pivot table reduces the redundancy of the table contents.
Think of it as flattening the one to many relationship
we just saw an example of on the last slide.
To create the pivot table, I need to identify
how I want my input table fields to be reorganized,
set my input field to JOIN ID, my pivot field.
That's the one I'm sort of rotating the table around
in a manner of speaking
and the value field to my area calculations
from the Summarize Within operation.
This means we'll list the area of value
under the correct buffer designation for each town
in a single record.
Result of this operation is shown in the lower left corner.
Remember the original version of the table had six rows.
Now we're down to three.
No repeats for the JOIN ID
and it treats each of those distances
as a separate attribute in the table.
If we look at the Summarize Within attribute table
on the top left and the pivot table on the lower right,
we see that a join is now greatly simplified.
And with that result, we can now use
that summary information to display the total area
of each town that is comprised of trail buffers.
That's it for vector data.
In the last lecture of this learning module,
We'll revisit data approaches to summarizing raster data.