Lab 2 Qgis
Lab 2 Qgis
What You’ll Learn: In this Lab you’ll be introduced to basic digitizing techniques using
QGIS. You should read Chapter 4 in the GIS Fundamentals textbook before starting
this lab, as the chapter covers the basics of data entry, properties of hardcopy maps,
and digitizing mechanics.
Data are located in the \L2 subdirectory, including Boat_Docks.shp, Houses.shp, and
Islands_in_River.shp, files with errors that you’ll fix, and Lab2_image.img, an image file
that you’ll use as a data source. All data are in UTM Zone 15, NAD83 coordinates.
Manual Digitizing
Digitizing is the process of interpreting and converting paper map or image data to
vector digital data. In manual digitizing you trace the lines or points from the source
media. You control a cursor, usually with a mouse or digitizing puck, and sample
vertices to define the point, line, or polygonal features you wish to capture. The source
media may be hardcopy, e.g., maps taped to a digitizing table, or softcopy, e.g., a digital
image or scanned map. QGIS software allows us to digitize using either hardcopy or
softcopy sources.
Create a new directory, preferably on your USB drive, and copy the Lab 2 data
there
Start QGIS and create an empty/new project
1
Digitizing
Select the Add Raster Layer button ( ); navigate to the \L2 folder, and add the image
named lab4_image.img. An image should be displayed, similar to that shown below:
This is an area near Stillwater, Minnesota, with a mix of forests, houses, and farm fields.
The St. Croix river runs through the eastern (right) part of the image.
When it first displays, the coloring isn’t the best; it’s a bit too bright, and the fields a bit
washed out. We will first adjust the image “stretch.”
Right click on the image name in the table of contents (TOC), and left click on
properties, then select Style to display a window that allows you to control the
symbology:
2
In the upper right is a set of buttons for changing the coloration, under the heading load
min/max values.
Click on the button labeled Mean +/- standard deviation x, and change the number in
the adjacent box to 2.0,
This should provide a better color stretch. There are various other settings, you can
experiment, and if you make the image unviewable, you can always remove the image,
3
add it back, and apply the +/- 2 standard deviation stretch.
The image is an orthophoto registered to the NAD83, UTM zone 15N coordinate
system, thus the coordinates are visible at the bottom of the image, and the EPSG
number displayed
Inspect the image with the zoom and pan utilities (remember, magnifying glasses and
hand discussed in the first lab).
Digitizing Features
Your goal is to digitize points (ponds), lines (major roads), and polygons (selected fields)
from this image. See the map at the end of this document for the minimum number of
roads, ponds and field you need to digitize; you can do more if you wish. You don’t have
to do exactly the specific features in the map, just an approximately equal number of
features.
You’ll need to create three new data layers, one each for points, lines, and polygons,
and digitize different features on the map.
Left click on New Shapefile Tool, often docked on the left sidebar:
4
a large error in the data. Too large a scale is inefficient, e.g., digitizing at 1:100 you will
be very accurate but will require frequent panning. The best scale depends in part on
the level of accuracy you need, and how the features you wish to digitize appear on the
images.
Find the editing cluster of tools (see below), usually a horizontal series of icons near the
upper-left side of the main QGIS window. The tools are detachable, and may be in a
different place, set up as free floating, or along the left or right edge or along the bottom,
so you may have to search for them on different systems.
The tools allow you to add or modify features. Note that not all icons work for all
features, some are just for points, some just for lines, some only for polygons, nor are
the actions exactly the same, depending on the features you are editing. If you “hover”
the mouse pointer over an icon, hold it still without clicking, a banner name of the tool
should display.
Click on the pond layer in the table of contents, then click on the Toggle Edit
button to open the pond layer for editing:
Pan and zoom until there are several ponds visible in the image.
Note the cursor now changes when you move it over the image, to a cross and circle.
This indicates your left-clicks will add data.
To digitize points place the cursor over a pond, and single left-click. Each click creates a
feature. A window will open, asking you to enter an ID for the pond, and perhaps other
5
attributes (depending on how you specified the layer).
Navigate and digitize at least 20 ponds as new points. Place the point in the middle of
the pond by positioning the cursor and left-clicking.
If the default point symbols are difficult to see, you can change the symbol color, size, or
type by double clicking on the legend entry for the layer in the table of contents, as you
would for any theme.
Note that when you select other functions during digitizing, e.g., changing the color or
size of a symbol of another layer, you may have to re-activate the point data layer you’re
adding features to by clicking on it in the TOC, and then continue digitizing.
You should right click on the ponds layer in the TOC left click on Save Layer Edits
every few features, and when you are done digitizing ponds. QGIS can crash, and
you’ll lose any unsaved work.
You can edit existing point features with the Node Tool:
You activate features for editing with the node tool to move them. Activate the node tool
and left click on the feature. Note that a (typically red) box appears around the point
you have selected.
When you click and hold on the active feature the colored box should change to blue,
then continue to hold and drag to move a feature.
In an alternate sequence, you can select features with the Select Single
Feature Tool:
Clicking on a feature in the active layer (the one highlighted in the TOC) selects it and
colors it (typically yellow) to indicate it is selected.
You may then activate the Move Features Tool, and click-drag to reposition:
If you wish to delete a feature, you must first select it with the Select Single Feature
Tool.
Delete the feature by pressing the delete button on the keyboard, or the Delete
Selected Feature Tool on the editing toolbar:
To de-select feature(s), left click on QGIS canvas somewhere off of the feature, or on
6
Deselect Features From All Layers Tool:
The features should then be deselected, and the color should now match the rest
of the features.
Finish digitizing all your ponds, save your edits, and stop editing (click on the Toggle
Edit button).
7
Digitizing Line and Polygon Features with Snapping
Next we’ll digitize lines and then polygon features, but first we should set the snapping
environment. You should read about snapping in Chapter 4 of the textbook before
doing this section.
You specify the snap mode, whether it is on, snaps to just vertices, or both to vertices
and lines.
You then set the snapping tolerance, the distance to which things may be snapped.
Typically these are set in map units, meters for this case, because these have a direct
physical measure, and you won’t be confused if you have multiple images displayed.
As noted in the book, you set the snapping tolerance below the spatial accuracy
required for your work, but large enough to speed up digitizing, say, 1 to 4 meters here.
8
You can also choose the search radius for vertices when you are editing, to make it
easier to select points or line nodes.
There is a check a box to add a snapping options dock when starting QGIS, but this
won’t take effect until the next time you start the project in QGIS.
Set the units and options as you desire, and then click OK
You may change the options after digitizing a bit if you find you’ve set your snapping
tolerance too high or low.
With snapping set, we’ll digitize line features into the roads data layer. Create a roads
layer if you haven’t already, then add and select it in the canvas.
You’ll digitize the set of roads shown in the map at the end of these instructions.
Set your scale to something like 1:4000 to 1:8000, and Toggle Editing for your roads
layer.
Click on the Add Feature Tool, notice its different appearance for lines:
Note that lines you’ve completed are shown as black with red crosses. You can change
the color/shape/transparency settings in the QGIS-Preferences-Digitizing options
described just previously, but note that the changes don’t take effect for a feature you’re
currently digitizing.
If the entire road segment you wish to digitize is not in the view, you can navigate
around the image using the pan and zoom tool while a feature is being edited. The
feature remains live when you move the cursor off of the “canvas,” but you don’t add
9
any new points while you have the pan or zoom tools activated. Be careful when
clicking on tools in the margin of the window, if you accidently click in the data pane you
will add a line segment you typically don’t want. You can always delete the vertex.
After you are done repositioning/scaling the image with pan or zoom, you must click
again on the Add Feature Tool in the Create Features window to return to the digitizing
cursor. When you select the Add Features Tool, the last feature you were working on
becomes active, and you take up digitizing where you left off.
If you’ve already ended a line and decide there are too many errors to fix by editing, you
can remove the entire last line you digitized by selecting Edit-Undo from the main QGIS
menu.
Note that if you move the cursor near an existing vertex (cross), when you get within the
snap tolerance, the vertex changes color (purple in my installation). This indicates
snapping will occur when you digitize, matching the vertices.
Digitize a few more road features from the set on the map at the end of these
instructions.
Fixing Mistakes
What if you make a mistake on a few vertices while digitizing, and don’t notice them or
decide not to fix them until you’re done?
Activate the Node Tool and click on the offending vertex or line. All vertices for
the line should be surrounded by a box.
You may then click-hold on the vertex, and hold-drag to reposition it.
If you wish to remove an entire line, you may use the Select Single Feature Tool
and the delete key or Delete Selected Feature Tool to remove it.
You may select several lines by holding down the command key (Mac) or shift key
(Windows), and left clicking on each of them to select, then delete or move en masse.
To move an entire line you select it, then activate the Reposition Feature Tool
and click-drag to move it. Note that the entire line will move, but its connections
to adjacent lines will not be maintained, i.e., snapping just puts the ending vertices for
adjacent lines in the same place, but does not attach or “weld” the lines together.
Digitize and fix mistakes until all indicated roads are digitized. Remember to set and use
your snapping tolerance so you don’t have under- and overshoots. Save frequently
10
using Editor > Save Edits, and stop editing when you’ve digitized the roads shown in
the example map below. You can digitize more than the example map roads.
Now add a new polygon layer named something like “fields”, making sure to click the
polygon radio button, and specifying the NAD83 Zone 15 UTM projection when creating
the layer.
Use the Add Feature Tool to digitize field polygons, noticing the icon has changed:
There are two other settings you can use to avoid most gaps and overlaps where the
field edges join.
Set up the snapping options as shown below, making sure to check the box under Avoid
Int. next on the right side of the fields row:
It helps to set the data layer as semi-transparent. Do this in the symbology (remember
where? Right click TOC, Properties, Style). There is a slider for transparency; if you
move it somewhere towards the middle you’ll be able to see through your already
digitized polygons.
11
Digitize the fields shown in the
example map.
Save frequently.
Using a WMS
So far, we’ve provided the images you’ve used, and you often download and clip
images for a study area because it is easiest or most convenient or efficient to work with
locally-stored images. There is an alternative that is becoming increasingly available,
known as a web mapping service, or WMS. An organization, typically a government
organization, stores and serves images over the internet. Any time you have an internet
connection you may access the images. A wider catalog over a larger area may be
accessed this way, at the cost of needing a relatively fast web connection, sometimes
restricting the coordinate system you can work in while digitizing, and the contrast
stretch or band combinations you can show. We’ll show you how to use a WMS for our
work area, but you may apply this tool anytime and anywhere you need data and a
WMS is available.
You start by identifying a WMS URL. This is the address the GIS program needs to
access the images. In our case, the Minnesota Geospatial Information Office, or
MNGeo, provides a great catalog of images and other data through various image
services. A listing of the services can be found at:
http://www.mngeo.state.mn.us/chouse/wms/wms_image_server_specs.html
In our case we want digital orthophotographs, to use as a base for digitizing, so we
12
need to access the URL:
http://geoint.lmic.state.mn.us/cgi-bin/wms?
We create access to a
WMS through the Layer –
Add Layer – Add
WMS/WMTS Layer panel,
accessed along the top of
the main QGIS frame:
13
Click on the Connect button to the left of the
New button (see right), and a list of
images/image categories should appear.
Select the 105 – stretch image by clicking on it, then click on Add at the lower left of the
large window, and this should display the layer, something like what’s shown below.
Zoom to our study area, in the green circle noted in the image below.
14
Load
a few more layers, e.g., look at the Statewide layers (156), and select one of the later
year FSA images (e.g., 2010 color, shown below right).
If you do load more Twin Cities Metro images, note that many of them don’t reach to our
study area, and are for only a subset of the region.
Leave one of these WMAs displayed, or display the original image, and go on to the
next step, editing shapefiles.
15
Editing Shapefiles
Add the following shapefiles to your data view:
Boat_Docks.shp
Houses.shp
Islands_in_River.shp
Specify a display scale of 1:1500, because we’ll need to view these data with a high
magnification to edit them.
These layers have errors. The houses are not in the correct places, the Islands include
water, and the boat docks are unconnected or in the river. You will fix all three, using
the tools you learned above.
Toggle editing on with the layer to “Houses” selected in the TOC, and use the Node
Tool to reposition the house features. By appropriate zooming you should be able to
identify houses on the image. Remember to click once on an existing point feature to
display it as a red square, then a second click-hold-drag to reposition the point feature
correctly over a house.
You may need to recolor/resize the features for easier viewing. You may need to add
and/or delete house features, using the tools learned above.
During and after correcting all house errors, save your edits.
Load and display the Boat_Docks. Set the snapping tolerance to between 2 to 3
meters.
Zoom to layer extent (right click on name in TOC, then select in the dropdown).
You may have to re-color the symbology so that lines are conspicuous, changing the
thickness and color. Red or yellow are not recommended, because selection and
digitizing defaults include these colors.
Make sure editing it toggled on, and fix the two errors:
16
- the unconnected docks in
the northwest corner (upper
left of the boat dock
features)
- trim the too long dock at the
southern end (bottom of boat
dock features)
17
Finally, fix the Islands_in_River shapefile. Load it, perhaps change to a hollow
symbology, and set the snapping tolerances properties, and the snapping options.
The four errors to fix, starting from the upper left corner and moving clockwise, are:
- delete the spurious island to the northwest (left) of the larger islands
- reshape the northernmost island to match the tree/water boundary
- remove the overlap, and create one island from the two pieces
- split the polygon, removing the water from the middle and creating two distinct
polygons.
You may create new features or add vertices and reshape features as described above,
as well as splitting, reshaping, and other tasks that are accessed through the Editor
Toolbar.
18
To split a polygon into two parts, first make sure the
advanced editing toolbar is checked (see right figure).
To Turn In
Below is the
“approximate” Key
for your digitizing.
Digitize the Ponds,
Road and Fields and
correct the Houses,
Docks and Islands,
and produce a PDF
that looks
approximately like
the image below.
Remember to
include a North
arrow, legend, title,
your name, and
scale.
19