What You’ll Learn: to apply the concepts of buffering and overlay, two common cartographic operations. You should read the sections on buffering and overlay in Chapter 9 in the GIS Fundamentals textbook.
Data: All data are in L9.zip file, including:
lakes.shp
roads.shp
public_Hugo.shp
https://github.com/mapninja/Earthsys144/raw/master/data/L9.zip
What You’ll Produce:
Two maps, of
- lake and Road buffers
- suitable recreation areas on private land.
- Create a new QGIS project and add the roads.shp data layer.
- Left click Vector on the top toolbar and then Geoprocessing Tools -> Buffer
There are options to specify the input feature layer, the buffer distance and units, and the output.
- Specify “Dissolve results” because otherwise the tool generates multiple, overlapping polygons.
- Use the parameters shown below and add the result to your project when finished.
The roadsBuffer300m
layer should look something like that below, here re-arranged to show the roads on top, and the buffer in purple below.
5. Redo this buffer, but this time; leave the default Dissolve buffer results UNCHECKED. Make sure to open and view the attribute table associated with each buffer layer.
How do the results differ?
When would this be important?
After inspecting, remove the undissolved layer.
The second exercise will buffer the Lakes.shp
layer using a variable distance buffer (Video: Variable Distance Buffer).
The buffer distances are:
- A buffer distance of
50 meters
for lakes with sizeclass 1
- A buffer distance of
150 meters
for lakes with sizeclass 2
- A buffer distance of
500 meters
for lakes with sizeclass 3
There are three main steps:
- Open the lakes attribute table and insert a field to hold the variable buffer distance.
- Select by Attributes and use the Field Calculator to assign distance values for the variable buffer distance to groups of features, by size class
SIZE_CLS
. - Apply the buffer operation.
- Make sure the
Lakes.shp
is in your project, and open its attribute table. - Use selection features by expression to select the lakes with
SIZE_CLS = 1
.
- Use the Field Calculator to create a new whole number (integer) field named something like
buffdist
, with a value of50
. - Make sure that you have the option checked for only updating selected features, near the upper left of the tool. Apply the calculation.
- Now, Select those features with
Size_CLS = 2
, and use the** Field Calculator** to Update an Existing Field, assigning150
to thebuffdist
variable.
5. Repeat the select/assign process for lakes with Size_CLS 3, assigning a
buffdist
of 500
.
-
Unselect any selected polygons or the buffer will only be applied to those selected using the Unselect all features button
Check that your table is correct, e.g., similar to the example figure at right. Note that the last two columns, SIZE_CLS and buffdist, should change in concert, with a larger buffer distance appearing for larger size classes.
- Use the same buffer tool as we introduced previously (Vector->Geoprocessing->Buffer).
- Specify
Lakes.shp
, and also make sure to check the option to Dissolve the result - Specify a variable distance buffer through an option box, accessed by clicking on a small box at the far right of the distance/units option (see arrow below).
This allows us to open a sequence of dropdowns:
- Choose Field type:
int, double, string...
, and thenbuffdist
as the variable that contains the buffer distance (see figure below). - specify an output, something like
VarBuffLakes
, and run the tool.
This should create a layer similar to that below. Note the buffers are larger for the larger lakes, as per our specified buffer distance variable.
Arrange the roads, dissolved fixed distance road buffer, lakes, and variable distance lake buffer layers so that you can see all three, as in the figure below.
Save here and proceed to the next part (scroll down). Remember to save often.
Create and export a layout with the roads, lakes, and their buffers, as in the view shown below.
Make sure the order is as shown here, so you may see most of each layer. The order is, from the top:
- roads,
- lakes,
- lake buffer
- road buffer
label each layer with descriptive text in the TOC/legend, and be sure to include a scale bar, north arrow, title and your name.
Our goal in this exercise is to find potential campgrounds for a State Park. A campground needs to be close to lakes, but these will be drive-in sites that must also be close to roads. The final map will show locations that are both within 50, 150 or 500 meters of a lake (depending on the size of the lake) and within 300 meters of a road.
You have already created your starting layers. These are the variable distance lakes buffer and the fixed distance roads buffer from the previous exercises.
We need to modify input layers prior to overlay so that we may easily interpret the results after overlay.
First, we must turn the buffer output to single part features. Buffer returns multipart features, which means there may be multiple polygons for a single row.
- Open the attribute table for
VarBuffLake
, you should see just one row, while the layer obviously has many polygons.
- To convert this multipart layer to single parts, use Vector->Geometry Tools-> Multipart to Singleparts, naming the output something useful, like:
SingleLakeBuffers
- After running the tool, open the attribute table for the output. Note that there are now multiple entries, one for each polygon.
Also note that the buffdist
is now wrong, it has a value of 50
for all the polygons (or perhaps one of the other values, 150
or 500
is repeated, the one it saves appears somewhat random), even though the medium and large sized lakes had different buffer distances. Since the columns we have in this layer aren’t useful, it’s helpful to delete them:
-
Open the attribute table of the
SingleLakeBuffers
layer, toggle ON editing and click on the delete fieldtool.
-
Select all of the fields and click OK to delete them (it’s OK, don't be nervous! They aren’t useful!).
- Now, create a new column called
inlakebuff
in theSingleLakeBuffers
table, with a value of1
for all the lake buffer polygons, using the Field Calculator.
- Repeat the same steps for the
road buffer layer
:- Convert to SinglePart features, as
singlepartroadsBuffer300m.shp
- Clean the attribute table, deleting all the current fields
- Add a new attribute named something like
inroadbuff
, and assign it a value of1
to indicate it is inside the road buffer.
- Convert to SinglePart features, as
- Remember to toggle off editing and save for each layer when complete.
Before we overlay the two layers with the “Union” command, we need one more preparation step.
The SingleLakeBuffers
layer we created has buffered areas that include the lake as well as the land near shore. Campsites will be on dry ground, so we will use the Difference tool to remove the lake from the lake buffer layer.
-
Open the Vector>Geoprocessing Tools>Difference
-
Specify Input Vector Layer as the
SingleLakeBuffers
-
Specify the Difference Layer as the
lakes
layer -
Set the output destination to something like
LakeBuffersOnly.shp
-
Click Run
Display the output and verify that the results are the lakes buffer layer with the lakes area removed:
- Select Vector>GeoprocessingTools>Union
- Specify the input layers –
LakesBuffersOnly
(as the input layer) andsinglepartRoadsBuffer300m
(as the overlay layer) - Specify the output layer something like
BufferUnion
, and Run.
-
Open the attribute table and examine the new
BufferUnion
layer. -
Scroll down the table and find a record for which
inlakebuff
andinroadbuff
are both =1
. -
Click on the Numbered Square to the left of the record to Select it,
The selected polygon meets both the road proximity and lake proximity criteria.
Note that there also appear to be multiple, distinct polygons linked to this row.
QGIS groups polygons in the data files when performing analysis. When we are finished with our analysis we will “ungroup” polygons in the file, creating a table row for each polygon.
to create an expression that selects the features that have a value of 1 for both the inlakebuff and inroadbuff columns:
"inlakebuff" = 1 AND "inroadbuff" = 1
This should yield the selection, below. (HINT: right-click and Zoom to Layer to see the whole layer selection)
Upon visual inspection, these are the polygons within both the road and lake buffers.
-
With the selection still active, right click on the
BufferUnion
, then -
Export>Save Selected features as… as something appropriate, like
Candidates.shp
, and verifying that the option to Save only selected features is checked.
Display the data and verify that you have something like the following:
- Use the manual selection tool,
and verify that some of these are still multipart, by clicking on a few polygons.
- Be sure to clear your selection.
We have one final criteria to meet, that these campgrounds be on private land.
-
Add the
Public.shp layer
to your project. -
Use the Difference tool, as above, to create a new layer called FinalCandidates that excludes all **Public.shp **features.
The westernmost lakes should look like the figure here, with the public bits carved out of the lower lake:
Create a Layout that includes:
- roads,
- lakes, and
- lands suitable for campgrounds on private land
Label each layer with descriptive text in the legend, and include a scale bar, north arrow, title and name.
(HINT: I played with the “Layer Rendering for the FinalCandidate
layer, using Difference and then an Inner Glow from the Draw Effects option, at the bottom of the layer styling panel.