Exercice 1
Exercice 1
Exercice 1
E-mail: h.vanderkwast@un-ihe.org
In cooperation with:
These exercises will guide you through different steps that are needed to preprocess data to be used
in models and tools. In the first exercise you will learn how to register a scanned topographic map
and use it as a backdrop for digitizing vector data. In the second exercise you will learn how to import
data from spreadsheets into a GIS and to use it to join tables, manipulate the attribute table and
interpolating the data to a continuous raster layer. In the third exercise you will download open
access data from OpenStreetMap and use it for further analysis and conversion. The geodatabase will
also be introduced in this exercise. In the fourth exercise you will use map algebra for spatial
planning. Finally, you will learn how to delineate catchments and streams form digital elevation
models and to present them in maps or in an interactive webpage.
The exercises have been developed for different MSc programmes at IHE Delft and tailor made
trainings in Uganda, financed by the Vitens Evides International (VEI) fund. I would like to thank Jan
Hoogendoorn and Jonne Kleijer, GIS experts from VEI, for their contribution to these exercises. The
Adjumani dataset was developed by VEI and the National Water and Sewerage Corporation (NWSC)
in Uganda. I’m thankful for their permission to use the dataset for educational purposes.
In the near future we will further update the exercises and distribute it as Open CourseWare so the
whole community can use the course materials.
4
2 Introduction
You need an internet connection to download plugins or to use the open access data.
2.3 Preparation
Please note that QGIS is already installed on the laptops of UNESCO-IHE participants. Please do not
change the version and skip this section. The exercises have been tested for QGIS 2.14.x.
2.4 Convention
Throughout this guide we have used three different fonts according to what kind of operation we
wanted to point at:
5
3 Getting familiar with QGIS
It is made of the Standard System Menu or Main Menu (we will refer to Main Menu in the following
pages) which is always on the top of the software's window, of standard toolbars like the Zoom
Tools, or others that can be activated clicking in the Main Menu View and then Toolbars.
On the left hand side there is the Table of Content (Layers list) area, where all the layers displayed
are shown. To the left of this space there is a vertical toolbar, the Manage Layers toolbar.
In the centre of the window stay the Map Area, where all maps will be displayed.
More information about the QGIS Graphical User Interface can be found here:
http://docs.qgis.org/2.18/en/docs/user_manual/introduction/qgis_gui.html
6
3. Standard
2. Zoom & Other Tools
System Menu
1. Table of Contents
(Layers)
6. Open Different
Types of GIS Data
7. On-The-Fly (OTF)
Projection
7
Exercise 1: Digitizing from a scanned
map
8
4 Digitizing from a scanned map
4.1 Introduction
In order to use hardcopy maps in a GIS, they need to be scanned and georeferenced. Georeferencing
is also needed for raw remote sensing images, such as aerial photographs and satellite images.
For the best result, choose a map sheet that is clean and does not have too many folds. Use a
scanner that is large enough to scan the whole map. The resolution of the scanner should be large
enough (e.g. 1200 dpi) to have enough detail in the resulting raster maps.
For georeferencing we need to link locations on the scanned image to coordinates. There are two
ways:
1. Collect ground control points (GCPs) at locations that are clearly visible in the image, such as
bridges and junctions.
2. If the hardcopy map contains a coordinate grid, you can use the printed grid as a reference.
Make sure that you know the projection of this grid, which usually is stated on the map.
In this exercise we will use a scanned map of Mount Marcy (USGS, 1979)
(Mount_Marcy_New_York_USGS_topo_map_1979.JPG), which we will georeference with
the coordinate grid printed on the map. You can find the data (Data Exercise 1) on the
OpenCourseWare website (http://ocw.unesco-ihe.org/course/view.php?id=11). Save the map on
your hard drive (e.g.
D:\QGIS_Exercises\Exercise_1\Mount_Marcy_New_York_USGS_topo_map_1979
.JPG
9
4.4 Importing the scanned map into the Georeference GDAL plugin
1. From the main menu choose Raster Æ Georeferencer Æ Georeferencer…
10
Keep the other settings on default and check the box Load in QGIS when done. The dialogue
should look like the one below.
x The easiest way is to use the coordinate grid on the scanned map if this is available and if it is
in a known projection. We click on a node in the grid and type the corresponding X and Y
coordinates in the dialogue.
x Using a reference map in the QGIS map canvas that has already been georeferenced. In this
way we can obtain the right coordinates by clicking on the reference map.
x Using GCPs that were measured in the field using a GPS.
Here we will use the coordinate grid that is printed on the map.
1. Zoom in on the node with coordinate 581000 East and 4885000 North.
2. Click the Add Point button to add a GCP.
11
3. Enter the map coordinates in the pop-up window:
If you have a reference map in the QGIS map canvas, you can use the From map canvas
button to capture the coordinate and perform an image to image georeferencing. Here we
will only type the coordinates form the map grid.
The red dot is the location that you have referenced. In the table below the map, you can see
the Source X and Source Y coordinates. These are the unreferenced file coordinates. Their
values depend on which pixel you clicked for placing the GCP, so it can differ from the
screenshot above. Dest. X and Dest. Y show the real world coordinates that you have linked
to this location. The other fields of the table have to do with estimated accuracy and will be
filled in after adding more points.
5. Let’s choose a second GCP in the upper right corner of the map and proceed in a similar way
as with the first GCP. Your screen should look like this:
12
You can see that some error statistics have been calculated. With only two points this does
not make much sense. The minimum amount of GCPs for a linear transformation should be
4.
6. Add in a similar way a GCP in the lower left and the lower right corner of the map. If you
made a mistake you can remove the GCP by using the Delete point button . Your screen
should look like this:
At the bottom of the screen you can see the estimated mean error (40.4217 pixels in our
case). The error is also visualized at the GCPs using a red line.
13
There are two ways to reduce the error:
a. Use the button (move GCP point) to place the GCPs really at the nodes where
the grid lines cross. You need to zoom in to select the right pixel.
b. We can also change the transformation type. If we change to another transformation
type in the transformation settings, the error values will be recalculated.
We’ll apply option b.
7. In the menu go again to Settings Æ Transformation Settings… and now let’s select a 1st order
polynomial (Polyniomial 1) instead of the linear transformation. Keep the rest as it was. Click
OK to return to the GCP table. Now you can see that the mean error has been reduced to a
fraction of a pixel, which is acceptable. If you don’t see a mean error < 1, than you have to
check the GCP locations and correct them.
8. Now we can start georeferencing using the button. After some calculation time the
georeferenced map appears in the QGIS map canvas. You can close the Georeferencing
plugin. It will ask if you want to save your GCPs. You can click Discard if you don’t want to use
them. If you save them, you can load them again in the Georeferencing plugin.
9. In order to verify the result you can use the Coordinate Capture plugin. If it is not activated
yet you can do it by choosing from the menu: Plugins Æ Manage and Install Plugins… . Then
search for the Coordinate Capture plugin and check the box to activate and click Close:
10. A panel has appeared under the layers list. Here you click on Start capture. Click on a grid
node in the map and the coordinates are displayed in the panel:
Read the coordinates from the side of the map and verify if they are correct.
11. Another way to verify the result is to use the QuickMapServices plugin web maps as a
backdrop. If not yet installed, install the QuickMapServices plugin: in the main menu choose
Plugins Æ Manage and Install Plugins… and search for the QuickMapServices plugin and
install.
14
After installing, choose from the main menu Web Æ QuickMapServices plugin and try some
of the options.
1. First we have to create an empty shapefile. In the main menu select Layer Æ Create Layer
Æ New Shapefile Layer…
2. In the New Vector Layer dialogue we specify that we are creating a Point layer. For the CRS
we select the one of the topographical background map (EPSG:26718). You can use the
arrow to choose the right projection from the dropdown list. Next, we have to create a new
attribute. In the attribute list you can see that by default there is an attribute called id. We
will create one with the name Elevation. For type we choose Whole number and Width 4.
This means that we can store integer values up to 9999, which is sufficient for any mountain
on Earth.
3. Click the button Add to attributes list. The attribute is now added. The dialogue should look
like this:
15
4. Click OK.
5. Browse to the folder where you want to store your data (e.g.
D:\QGIS_Exercises\Exercise_1) and name it peaks.shp and press OK.
6. The empty shapefile has now been added to your layers list.
7. In order to start digitizing, you have to toggle to edit mode. Click on the peaks layer so it is
selected.
8. Click on to toggle to editing mode. Now the other editing buttons become active and a
pencil before the layer name shows that we are editing the layer.
9. In the topographical map navigate to a spot height of a mountain. They are indicated with x
and an elevation value. If you have found one, zoom in and click the Add Feature button .
10. Move the mouse to the mountain top. The cursor changes in a crosshair. Click on the
mountain top.
11. A dialogue with a form shows up. Here you can fill in the attribute values: id = 1 and
Elevation = 738
12. Repeat this step for a few other peaks. If you made a mistake, you can use to select the
point feature and to delete the selected point feature. This button can be used to
move a point feature. Use to save the edits.
13. When done, click again on the button to toggle editing. If you didn’t save edits yet, it will
ask you to Save or Discard. With Discard you can always undo your edits until the last time it
was saved.
14. You can check the attribute table of your new point vector layer by right clicking on the layer
name (peaks) and selecting Open Attribute Table
16
Now you can see the attributes that you have added and their id and elevation values.
15. Our next task is to digitize line features. The procedure is similar to creating a point layer. In
the New Vector Layer dialogue now you choose Line. As a new attribute we add River
Name with the type Text. Keep the width at 80. Check if the dialogue resembles the one
below and click OK. Call the new vector layer streams.shp.
16. In the layers list select the streams layer and toggle editing.
17. Click on to add a new line feature. Zoom and pan on the map to find a stream to digitize.
18. Click on the starting point of the line (node) and click when necessary to make a vertex. You
can use the zoom and pan buttons to trace the stream. You can also change the symbology
to visualize clearer the line that you are digitizing. After you placed the end node of the line,
click right. You can use the spacebar to pan during digitizing.
17
20. Repeat these steps for a few streams and save your edits. Check the attribute table. If you
want to add tributaries that connect to streams, play around with the snapping settings (in
the main menu go to Settings Æ Snapping options…).
21. Finally we are going to create a polygon vector layer for some lakes. Try to find out yourself
how to do this. It is very similar to the procedure for lines. The only difference is that the first
node should be the same as the last node in order to close the polygon.
18