0% found this document useful (0 votes)
43 views

Lab 2 Qgis

This document provides instructions for digitizing features from an image into vector layers in QGIS. It describes how to add the image, adjust its symbology, and create new shapefiles for points, lines and polygons. The task is to digitize at least 20 ponds, roads, and fields from the image into the corresponding layers.

Uploaded by

gondalgondal5757
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Lab 2 Qgis

This document provides instructions for digitizing features from an image into vector layers in QGIS. It describes how to add the image, adjust its symbology, and create new shapefiles for points, lines and polygons. The task is to digitize at least 20 ponds, roads, and fields from the image into the corresponding layers.

Uploaded by

gondalgondal5757
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Lab 2: Digitizing in 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.

Screen Digitizing in QGIS


Our practice exercise will involve digitizing a set of features from a scanned photo.
Digitizing directly from a screen is sometimes called “heads-up” or softcopy digitizing.
Digital cameras are common, so softcopy digitizing is a standard procedure. Scanned
photos have some geometric distortion that depends primarily on how the photo was
taken (flying height, terrain, camera tilt, and other factors). GIS data are commonly
entered from scanned photos because we can easily adjust the display scale, zooming
as needed. This often reduces both interpretation and digitizing errors.

Setting File Properties


As described in Lab 1, before you get started you should:

 Create a new directory, preferably on your USB drive, and copy the Lab 2 data
there
 Start QGIS and create an empty/new project

 Save the project to the just created directory (Project, Save)

 Set your path names relative to that directory

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,

then click on Load below the box,

then Apply at the bottom of the menu.

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:

A window pops up that allows you to select


the type of layer through buttons along the
top, specify the CRS, and add attributes.

Here, don’t bother adding attributes, just


change the CRS to match that of the image
(look up the ESPG number on the display),
hit o.k., name it Ponds, and save it into your
Lab 2 directory.

Now we’ll create new point features for the


ponds layer.

Use the pan and zoom tools to zoom to


inspect the image. Note that there are
several ponds, dark blobs in the fields,
often surrounded by a light- and/or
brownish-colored ring. Your task is to
digitize at least 20 ponds; we’ll get to that in
a minute, but first a few words about scale.

Scale is important when digitizing. Too


small a scale magnifies errors, e.g., at 1:50,000 a small error on the screen translates to

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.

Right click on the Lab2_image in the TOC and select Zoom to


Best Scale (100%). Notice you now zoomed to something like
1:900. This is probably larger than needed for this Lab. You can
directly enter a scale in the scale box along the bottom of the
display; here use 1:4000, a good compromise (simple type 4000,
without the comma or the 1 and colon, in the data view scale
box), or select an appropriate scale, if listed, from a dropdown
menu activated by the caret on the right side of the scale box (see
image at right).

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:

The button should appear “shadowed” as shown above, indicating it is active, or in


editing mode.

Pan and zoom until there are several ponds visible in the image.

You use the point tool to add points.

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:

Practice with a few ponds/points.

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).

Note that most of the editing functions are


available via the Edit Menu, a dropdown list from
the main QGIS toolbar along the top of the
canvas or screen:

The Undo, at the top of the menu, is perhaps the


most useful tool not yet covered. This “rewinds”
your last action, particularly helpful when you’ve
done something you regret.

Also note that there are keyboard shortcuts for


some of the actions, and these are shown to the
right of the tool. Most of the shortcuts begin with
an escape character, the command key (⌘) or
shift+⌘ key on Macs, and cmd or control keys
on an MSWindows computer. Sometimes it is
helpful to learn them for oft-repeated actions.

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 set snapping via the QGIS-Preferences menu, found on the


main toolbar at the top right of the QGIS window frame:

Click on Preferences and select Digitizing in the left options


column of the menu.

This displays a set of options that you may select via


checkboxes, pick lists, or numeric entry.

You may suppress the


attribute form that
appears when you
digitize each feature
(near top, check box),
change how things
appear when digitizing.

You can change the color


or transparency of
features or lines you are
digitizing via the
“Rubberband” settings,
especially helpful when
digitizing polygons from
an image, as we’ll do
below.

Right now we’re


interested in the Snapping settings, near the middle of the menu.

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:

Move the cursor to the start of the road you wish


to digitize, and left click. Move along the center of
the road, left-clicking when you need a vertex.
Note that this shows completed segments for the
current line as solid red, and the segment you’ve
digitized as dotted red.

If you make a mistake while digitizing, you can hit


the delete key on the keyboard to remove the last
vertex, provided you do this before “ending” a
line.

End the line with a right click.

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.

Start digitizing a new road feature.

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.

First, set your snapping tolerances (QGIS-Preferences) at something reasonable, about


3 to 6 meters, and set snapping to both vertices and segments.

Second, use the Settings-Snapping Options from the QGIS main


menu bar to further set up the snapping environment.

This will display a window that allows you to specify


-snapping on intersection
-enable topological editing (clip overlapping polygons)
-avoiding intersections when you digitize overlapping areas

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:

This setup won’t


automatically
avoid gaps, so
you have to be
careful to slightly
overlap adjacent
polygons or have
the lines/nodes
exactly match
through
snapping, but
you can produce
relatively clean polygons using these few options and care in digitizing.

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.

Move the cursor to a border of


the field you wish to digitize and
left-click the mouse. This starts
a new polygon.

Each time you left-click, you will


be placing a vertex for a
polygon, until you double click,
which closes the polygon.

Move the cursor to the next


field, and repeat the digitizing
process.

Continue digitizing features, at


least as many as are shown in
the sample map at right.

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:

This displays a window, in the


background at left. Clicking on
the New button (circled) displays
another window, in which you may
enter any title, and the URL as
shown, copied from the MNGeo
site, or the line specified above.

This is the specific URL for the


MNGeo image catalog, it would be
a different URL for a different
catalog, either from MNGeo, or
from another agency or different
state.

Click OK, and this should close


the window containing the URL,
and now display the new name
you entered at the top of the main
WMS window.

13
Click on the Connect button to the left of the
New button (see right), and a list of
images/image categories should appear.

Click on the triangle


labeled 86, then in the
dropdown list on the
triangle labeled 105.

You may need to drag


columns wider to see
the image names, do
this by hovering over
the thin line separating
the Name, Title, or
Abstract headings until
the resize handle
appears, then left click
and drag.

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)

Save your edits and stop editing.

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).

This should display a set of tools, typically below or to


the right of the normal editing toolbars.

Find the Split Polygon Tool:

You use this tool to split polygons in an editable layer by:


 selecting a polygon
 activating the split polygon tool
 digitize a node outside of but adjacent to the
polygon you wish to split
 digitizing across the polygon along the split path,
ending the path outside the polygon

This should split the polygon into two parts.

Fix all the errors in the layer, saving frequently.

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

You might also like