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

Exercises Open Source Software For Preprocessing GIS Data For Hydrological Models v2.18.11 PDF

This exercise teaches how to georeference a scanned topographic map for use in GIS. The steps include: 1. Scanning the map at a high resolution and saving the image file 2. Identifying the projection used on the map, in this case UTM zone 18N 3. Activating the Georeferencer GDAL plugin in QGIS 4. Adding the scanned image and assigning ground control points using the grid lines on the map 5. Georeferencing the image to align it with the correct map coordinates Once georeferenced, the scanned map can be used as a backdrop layer for digitizing vector data from the map.

Uploaded by

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

Exercises Open Source Software For Preprocessing GIS Data For Hydrological Models v2.18.11 PDF

This exercise teaches how to georeference a scanned topographic map for use in GIS. The steps include: 1. Scanning the map at a high resolution and saving the image file 2. Identifying the projection used on the map, in this case UTM zone 18N 3. Activating the Georeferencer GDAL plugin in QGIS 4. Adding the scanned image and assigning ground control points using the grid lines on the map 5. Georeferencing the image to align it with the correct map coordinates Once georeferenced, the scanned map can be used as a backdrop layer for digitizing vector data from the map.

Uploaded by

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

Exercises Open Source Software for

Preprocessing GIS Data for Hydrological


Models

Dr. Hans van der Kwast


Senior Lecturer in Ecohydrological Modelling
Water Science and Engineering Department

E-mail: [email protected]

In cooperation with:

September 2017, version 2.18.11


OpenCourseWare
ocw.un-ihe.org
Contents
1 Preface ............................................................................................................................................. 4
2 Introduction ..................................................................................................................................... 5
3 Getting familiar with QGIS............................................................................................................... 6
4 Digitizing from a scanned map ........................................................................................................ 9
5 Importing tabular data into a GIS .................................................................................................. 20
6 Importing data from a GPS and conversion to vector layers ........................................................ 34
7 Spatial planning using map algebra............................................................................................... 46
8 Inaccessible wells .......................................................................................................................... 64
9 Catchment delineation .................................................................................................................. 66
10 Using Open Access data ................................................................................................................ 95
11 Create 2D and 2.5D maps ............................................................................................................ 106
12 Styling and map design................................................................................................................ 111
References ........................................................................................................................................... 123
Links ..................................................................................................................................................... 123
Screencasts .......................................................................................................................................... 123
1 Preface
A Geographic Information System (GIS) can be a useful tool for preparing the input of models and
tools. Furthermore, in this era of Open Data ample open access data is available that can easily be
retrieved from the internet and integrated in open source desktop GIS software, such as QGIS.

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

2.1 Learning objectives


After following this step-by-step tutorial you will be able to:

 Use QGIS in its main functionalities, also in conjunction with plugins


 Digitize features from a scanned map or satellite image
 Import tabular data in a GIS
 Do simple vector analysis
 Interpolate point data
 Convert vector and raster data
 Reproject vector and raster data
 Use map algebra
 Use online data
 Perform catchment and stream delineation

2.2 Software requirements


During the next exercises we will make use of the following software:

 QGIS ver 2.14 (Essen) or higher,


 Google Earth,
 Firefox Mozilla
 MS Excel or OpenOffice Calc

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.

1) Download QGIS from http://www.qgis.org/en/site/forusers/download.html


2) Install QGIS
3) Install the exercise data from http://ocw.unesco-ihe.org

2.4 Convention
Throughout this guide we have used three different fonts according to what kind of operation we
wanted to point at:

 Calibri, is used for the main text


 Times New Roman, Italic, is used to identify software commands
 Courier New is used for text input, that is text that you have
to write in the software, or for file names

5
3 Getting familiar with QGIS

3.1 Start QGIS 2.18


You can start QGIS 2.14 Desktop by looking for it in the Start menu or using the search function.
Make sure you open the QGIS Desktop with Grass in order to have all functionality we need.

3.2 The screen


Like many commercial GIS also QGIS has a "traditional" GIS layout.

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

5. Data Sources 4. Map Area


Browser (blank right now)

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

4.2 Choosing the projection


Have a look at the scanned map and try to find the projection that has been used. You can use any
image viewing software for this. Which projection was used? Look for the EPSG code in
http://www.spatialreference.org and write it down.

4.3 Enable the Georeferencer GDAL plugin


The Georeferencer GDAL plugin is a core plugin, which means that it is already installed. In order to
use it, you need to activate it. This works as follows:

1. In the main menu go to Plugins  Manage and install plugins…


2. Search for Georeferencer GDAL and check the box
3. Click Close to close the dialogue

9
4.4 Importing the scanned map into the Georeference GDAL plugin
1. From the main menu choose Raster  Georeferencer  Georeferencer…

2. Click the Open Raster button


3. Browse to the Mount_Marcy_New_York_USGS_topo_map_1979.JPG file
4. A window will open where you have to specify the Coordinate Reference System (CRS) of this
input map. It does not yet have a CRS, so you can click Cancel.

4.5 Setting the transformation parameters


First we have to set the transformation settings (see also screenshot on next page).

1. In the menu choose Settings  Transformation Settings…


2. Here you can choose:
a. Different transformation types. A simple linear transformation can be used if the
map is not much deformed. The other ones can be tried when more deformation
exists. We will start with a linear transformation.
b. Resampling method: if you need the pixel values in further calculations, it is best to
choose the nearest neighbour option. This resampling method will preserve as much
as possible the original pixel values by choosing the nearest one. Visually, however,
this method results in a “blocky” map. If the purpose is only for visual use, for
example as a backdrop for digitization of vector layers, then it is better to choose
another resampling method. Here we will use the cubic method, which uses the
average of the 4 nearest pixels.
c. Target CRS: here choose the code that you have noted before; EPSG:26718
Browse to the folder where you want to save the georeferenced map. The tool automatically
adds _modified to the file name. So in our case the georeferenced file will be named
D:\QGIS_Exercises\Exercise_1\Mount_Marcy_New_York_USGS_topo_map
_1979_modified.tif

10
Keep the other settings on default and check the box Load in QGIS when done. The dialogue
should look like the one below.

4.6 Adding Ground Control Points (GCPs)


In order to link the file coordinates to real world coordinates, we need to indicate Ground Control
Points (GCPs) with known coordinates. We can derive these coordinates in different ways:

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

4. Press OK. Now your screen should look like this:

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.

4.7 Digitizing vector layers from a georeferenced backdrop


Our georeferenced scanned map can now be used as a backdrop to digitize vector layers. Vectors can
be points, (poly)lines or polygons. In this exercise we are going to digitize:

 Mountain tops as points


 Rivers as (poly)lines
 Lakes as polygons
The following steps guide you through the process.

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.

19. In the dialogue, fill in id = 1 and the name of the river.

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.

4.8 Image to image registration


Try to use the Georeferencer plugin to register the scanned map (JPG file) to a satellite image
from the QuickMapServices Plugin. In this way you can perform an image to image registration.
Please make sure you use the right projection. Does the image to image registration give better
results?

This whole exercise can be viewed in a screencast


at: https://youtu.be/4IWyVeGhzog

18
Exercise 2: Importing tabular data into
GIS and interpolation

19
5 Importing tabular data into a GIS

5.1 Introduction
After this exercise you are able to import tabular data into a GIS. In this example we are going to
import a table with the daily average temperature on September 1st 2013 at several meteorological
stations in the Netherlands. The data was downloaded from the KNMI Data Centre (KNMI, the Royal
Netherlands Meteorological Institute, http://data.knmi.nl), but reformatted for the purpose of this
exercise.

In this exercise we'll use the following data:

 KNMI_20130901_tday.xls: table with average daily temperatures for different stations


 KNMI_stations.xls: table with station number and coordinates of the location of the
stations

This data can be downloaded from the OpenCourseWare website (http://ocw.unesco-


ihe.org/course/view.php?id=11). You can find the data under Data Exercise 2. You can save the files
under D:\QGIS_Exercises\Exercise_2.

This exercise will guide you through the following steps:

 Import tables into GIS


 Join table with data to vector layer with locations
 Reproject dataset to local projection
 Recalculate values in an attribute table
 Interpolate vector to raster

5.2 Convert Excel table to GIS format


1. Open the files KNMI_20130901_tday.xls and KNMI_stations.xls in a
spreadsheet program (e.g. MS Excel) and check the contents. Which file contains
coordinates? Is there a way to link both files? How could we do that?

2. Start QGIS Desktop (make sure you start a new project and not continue the previous one).

3. In the menu go to Plugins  Manage and install plugins... and check if XyTools is installed. If
not, you should install the plugin. Plugins are developed by the community to add extra
functionality to QGIS. With the XyTools plugin you can import from/export to Excel files for
example. Note that XyTools can only work with .xls files. If you have files in .xlsx format,
you need to save it in .xls format from Excel.

4. Now in the menu choose Vector  XyTools  Open Excel files as attribute table or Point
layer

20
5. In the dialogue browse to the file with the locations of the meteorological stations
(KNMI_stations.xls).

6. Next you're asked to give the Coordinate Reference System (CRS). Here choose WGS 84
(EPSG:4326), which is lat/lon with datum WGS 84. Click OK to proceed.

7. Next, a dialogue pops up where you have to choose the columns with the x and y
coordinates. Which columns are those? Select those and click OK.

21
8. Now a map with the meteorological stations is displayed. If you don't see the map, you
probably need to zoom to the extent of the map: click right on the layer name (Temporary
layer (volatile) and choose Zoom to layer.

9. Rename the layer to KNMI_stations_table (Click right on the layer and select Rename).

10. Now add the table with the temperature data in the same way. When the Coordinate
Reference System is asked, click Cancel. When the popup comes that asks for the columns
with x and y coordinates, also click Cancel. This is because this table doesn't contain
georeferenced data. We have to link the two tables to make it georeferenced.

11. Rename also this layer. We call it KNMI_temperatures_table.

12. The next step is to convert KNMI_stations_table to a GIS vector format, i.e. shapefile. Click
right on KNMI_stations_table and choose Save as...
13. In the dialogue Browse to the folder to save the file as KNMI_stations.shp. In order to
change the projection to the local Dutch projection choose for CRS "Selected CRS" and

Browse to Amersfoort / RD New by clicking on the button. Tip: use the Filter field to
lookup EPSG code 28992:

22
Here you see the advantage of using EPSG codes: it standardizes the projection. So it is useful
to determine the EPSG code of the projection you want to work within your project. Also note
that all maps in your project need to be in the same projection if you want to combine them
in a GIS analysis or modelling.

Click OK. Now the dialogue looks like (also check the box Add saved file to map):

23
Click OK to proceed.

14. Remove the knmi_stations_table from the display by clicking right and selecting Remove. Be
sure to remove the right one. If you hover your mouse over the layer name it will show the
file name. With Remove you only remove it from the display, the file will still be on your hard
disk.

15. Although the knmi_stations.shp dataset is in the EPSG 28992 projection (Amersfoort /
RD New), the QGIS display still uses the EPSG 4326 projection (lat/lon WGS 84) and has
reprojected knmi_stations.shp on the fly for visualisation. In order to visualise all
layers in EPSG 28992 we have to change the QGIS Project properties. In the menu choose
Project  Project Properties...

16. Choose the Coordinate Reference System (CRS) tab.

17. Check the box "Enable 'on the fly' CRS transformation" (by default it is already checked, so
keep it checked).

18. Choose from the recently used coordinate reference systems EPSG:28992 and click OK.

24
Note that the projection of the project is indicated in the lower right of the screen

. You can always check there if the EPSG code is okay. You can change the
on-the-fly projection also by clicking on that EPSG code.

5.3 Join attribute tables


19. We still have the locations of the stations and the temperature data in separate tables. We
have to combine them in one shape file. In GIS terms this is called a "join" operation. We can
only join tables if they have a column in common. Check the attribute table of
KNMI_stations (right click on KNMI_stations and choose Open attribute table) and
in the same way check the KNMI_temperatures_table. Which column both attribute
tables have in common?

After determining which column both tables have in common we can join the data of
KNMI_temperatures_table to the attributes of our shapefile KNMI_stations.shp.

20. First close the attribute tables.

21. Next, click right on KNMI_stations and choose Properties.

22. In the dialogue choose the button Joins .

23. Click the + sign and choose check if the dialogue looks like this one:

25
Note that the common field is STN (the station number) and click OK.

24. Now the Joins dialogue looks like this:

Click OK to perform the Join operation.

25. Now check again the attribute table of KNMI_stations. What happened?

26. First we need to remove the missing values. Click on row numbers with NULL or no values for
temperature, while keeping the Ctrl button pressed. Now the attribute table looks like this:

26
27. In the attribute table click on above the table to toggle editing mode.
28. Click the icon (in the toolbar above the attribute table) to remove the 2 features with
missing data.

29. The only problem now is that the temperatures in the table are in 0.1 °C. We need to convert
the values to °C.

30. Click to add a new column to the table. And fill in the dialogue according to this
screenshot:

Length is the amount of numbers, Precision is the amount of decimals.


Click OK to proceed.

31. Now the attribute table shows an extra column with NULL values. In order to calculate the
right values click above the table to open the Field Calculator dialogue.

27
Fill the dialogue like the screenshot below. To avoid typos the best practice is to double click
on the field name in the middle of the dialogue screen and to click the * button. Then type
0.1. Click OK to proceed.

32. Make sure the Attribute table window looks like below. Please note that T(C) should be
indicated as column to assign the calculation to! Click Update All.

33. Now check the result in the attribute table.

28
34. Click again on the to toggle back to non-editing mode. Click Save to save the changes
when asked and close the attribute table. If you made a mistake, don’t save, but instead
choose Discard to undo all changes since last save.

35. Now remove the table KNMI_temperatures_table and check the attribute table of
KNMI_stations. What columns do you see now? What can you conclude about the join
function? You could have saved the entire attribute table by saving KNMI_stations to a new
shapefile using the previously used Save as… function.

5.4 Interpolate point features to raster


36. The final task is to interpolate the temperature values to a raster. In the menu choose
Raster  Analysis  Grid (Interpolation).
If you don’t see this, your GdalTools plugin is not activated. You can activate it from the
Plugins menu.

37. In the dialogue specify the output file: tday_NN.tif by using the browse window and
specifying the .tif format.

Check the Z-field checkbox and select T(C). This is the field that we will interpolate.
Check the Algorithm checkbox and select Nearest Neighbor. This is the interpolation function
that creates Thiessen polygons.
Check the Load into canvas when finished checkbox.
For the rest of the dialogue keep the defaults. The dialogue should now look like this:

29
Note that the dialogue generates a GDAL command that is given in the edit field.
Click OK to proceed.
Click 2 x OK to close the popup windows and click Close to close the dialogue.

38. The interpolated temperature map is now loaded into the display. It is visualised in greyscale,
so you have to set the visualisation options. Click right on the map and select Properties.

39. Under the Style tab, play around with the different options and click OK to return to the
display.

40. Now drag the knmi_stations file to the top in order to display the stations on top of the
temperature grid.

41. Click right on the knmi_stations layer and select Properties.

42. Select the Labels icon and choose Show labels for this layer. Choose T(C) as the Field
containing the label. Play around with the placement options (see screenshot below) to
make a nice map. Click Apply to test and OK to visualise.

30
43. Now repeat the interpolation using the Inverse distance to a power (IDW) algorithm (repeat
from step 37). Call the result file tday_IDW.tif. Visualise the result. Which interpolation
method is better? Why? Can you explain the temperature gradient in the map?

31
44. You can save your QGIS project at this point by choosing from the menu Project  Save as....
Now you can close QGIS and load the project the next time you use QGIS.

45. We can also plot our newly created GIS data over a topographical map. For this purpose you
have to install the QuickMapServices Plugin. In the menu go to Plugins  Manage and
install plugins... and install the QuickMapServices plugin if it is not yet installed. You can also
install the experimental additional services. You can do that under Web  QuickMapServices
 Settings.

46. Choose from the menu Web  QuickMapServices  OSM  OSM Standard. Make sure
your point vector layer is on top.

This whole exercise can be viewed in a screencast


at: https://youtu.be/LKNga7cedt8

32
Exercise 3: Importing data from a GPS
and conversion to vector layers

33
6 Importing data from a GPS and conversion to vector layers

6.1 Introduction
In this exercise you will learn how to collect data from a GPS, import the data into QGIS and create
point, line and polygon vector layers.

6.2 Preparing the survey


Before going in the field it is important to be well prepared. Fieldwork is expensive and you want to
prevent that you will have to go back. In the next sections there are some guidelines.

6.2.1 Preparation of maps


Use a GIS to prepare the following maps before going to the field:

 Use available maps to understand the study area


 Decide on the map projection that you want to use and look for the EPSG code
(http://www.spatialreference.org or http://epsg.io:
o Local projection: if your study area is in one country, you can choose to use a
national projection system
o Global projection: if your study area covers multiple countries, you can choose for a
global projection, such as UTM
o Unprojected: this is not preferred, but you can use latitude, longitude coordinates
(EPSG:4326).
 Create detailed maps (1:10,000) with a coordinate grid
 Print several copies of the map for different purposes:
o Field map, with numbered locations that you want to sample. Digitize the locations
in a GIS based on your understanding of the area. It is better to digitize more
locations than you can visit, because many will not be accessible in the field.
o Field map, where you note where you make a field observation, based on the
location you measured with the GPS and the grid printed around the map. Make
enough of these maps, because they will get dirty in the field. Always use a pencil to
write on the maps, because a ballpoint will not work with dust and humidity.
o Neat map. This is a map with your observation point that you keep at home and that
you update every time you come back from the field.

In this exercise we are going to survey de Markt in Delft, the Netherlands.

 Open QGIS
 Use OSM Standard from the QuickMapServices plugin to find de Markt (Zoom in on the
Netherlands, find Delft, zoom in on de Markt).
If the plugin is not installed yet, you can do it by choosing from the menu Plugins  Manage
and Install Plugins… . Then look for the QuickMapServices plugin and install it.
Your screen should be similar to this:

34
 Note that the projection of the Map Canvas is EPSG: 3857. In this exercise we will use
UTM Zone 31 North/WGS 84. Use http://www.spatialreference.org to find the EPSG code
and write it down. You need this also for setting up the GPS.
 Change the on-the-fly projection to EPSG: 32631, by clicking on the EPSG code in the
lower right of the Map Canvas.
 In the dialogue that follows, make sure that the Enable ‘on-the-fly’ CRS transformation
box is checked. Then select the EPSG: 32631 projection from the list (tip: use Filter).

35
Now the correct EPSG code should be displayed in the lower right of the screen. Zoom in well on the
square using the magnifier.

 Now from the QuickMapServices plugin choose the Google Satellite data to be displayed.
From the main menu choose: Web  QuickMapServices  Google  Google Satellite

If you don’t see this option, you need to go to settings and install the contributed services
pack.
Make sure that the image is on top of the layers list or uncheck the OSM Standard layer.

36
 This image can be saved to a GeoTiff, so we can also use it offline. From the main menu
choose: Project  Save as Image…

 Make a folder D:\QGIS_Exercises\Exercise_3 and save it as


Markt_Delft_UTM31N.tif

 Start a new QGIS project and discard the current one by clicking and click Discard in
the popup that will appear.

37
 Now add the raster layer Markt_Delft_UTM31N.tif by using this button

and choose the right projection when the dialogue shows up. Note that this GeoTiff is
georeferenced, but it does not contain the projection. It only has a world file (.tfw) that
contains the coordinates. Therefore, the projection needs to be indicated.

Now we are going to prepare your survey by digitizing points on the satellite image that you want
to visit in the field, e.g. buildings, statues, trees, etc. For now we only need to digitize Points and
give them an observation number. You can use this:

o T01, T02, etc. for trees


o S01, S02, etc. for statues
o B01, B02, etc. for buildings
o R01, R02, etc. for streets

Follow the steps below to do this:

 From the main menu select Layer  Create Layer  New Shapefile Layer…

 In the dialogue, select the correct projection and create an attribute Obs_Code

 Click Add to fields list


 Click OK
 Save the file as
D:\QGIS_Exercises\Exercise_3\Planned_observations.shp

The new, empty, shapefile has now been added to your Layers panel.

38
 Select the Planned_observations layer and click to toggle editing

 Click the Add feature button to start digitizing the points that we want to survey. Fill in
the attributes with the proper code.

 After digitizing toggle off editing by pressing again and chose Save.
 Now style and label the points in such a way that they are clearly visible in the map.

 Use the Print Composer to make a map with the points and a coordinate grid around. Export
the map to pdf and print the map on A3 format in colour and take it with you on the survey.

39
6.2.2 Observation forms
Depending on the purpose of your fieldwork, you need field observation forms. These can be forms
to observe land use, geomorphology, geology, household surveys, etc. Whatever form you need, it
always needs the following information:

 Observation number
 Name of the observer. This is important if you work in teams. Some observations are
subjective (e.g. visual estimation of vegetation cover) and it might be useful to relate it back
to the observer. This is also important if you need further information that is not covered
with the field forms.
 Date/time. This is very useful to link the observation to other time coded data, such as digital
photographs taken at the location, the GPS measurements or measurements from other
devices.
 Coordinates (X, Y, Z). Always write down the coordinates that you measure with a GPS at the
observation location. The reason is that the device can get damaged or lost. Also you might
lose the data when you return the GPS to the laboratory where you borrowed it from.

You can print the field forms and make a strong booklet that you can take into the field or use a
notebook. Always fill in the forms with a pencil. Ballpoints don’t work with dust and humidity.

After each field day, copy your field form to a neat form or a database on your laptop. Always make a
backup and store it in the cloud or on a USB stick that you don’t take with you in the field.

 Make a field form in your notebook for the survey of de Markt in Delft.

40
6.2.3 Preparation of the GPS
Before going into the field, please make sure that:

 You have enough spare batteries to take with you


 The GPS is complete with a USB cable
 You have tested that the GPS works and connects to your laptop
 Check GPS settings in the setup page. Check the time zone. The map projection and map
datum settings should correspond with the cartographic projection used on your field maps

 Prepare the GPS with the guidelines above.

6.3 Surveying using a GPS


You are now ready to use the GPS for measuring your location in the field. Pay attention to the
following guidelines:

 Wait marking your location into the GPS or writing down the coordinates until the handheld
GPS is receiving sufficient satellites with reasonable strength.
 Apart from writing down in your field book the coordinates, write also down the EPE:
Estimated Point Error. It indicates how accurate the GPS reading is horizontally in meters.
Accurate GPS readings typically have EPE’s around 3-5 m.
 Always use GPS and a together in the field. Always mark your position not only in the GPS or
in GPS coordinates but also on your field map and verify that you know where you are.
 Be aware that satellite reception can sometimes be poor under a dense forest canopy, below
escarpments and in dense urban areas and hence position computation becomes less
accurate. Always check the EPE value.
 The vertical height information (Z coordinate) of the GPS unit can have significantly higher
inaccuracy values and is therefore not trustworthy. For a detailed height measurement, more
Differential GPS (DGPS) systems or barometric altimeters should be used.

For this exercise, choose an open area that you can use for practicing surveying, e.g. a park or a big
square. Try to find 3 types of objects:

 Points (e.g. trees, statues, wells)


 Lines (e.g. paths)
 Polygons (e.g. footprint of a house, terrace of café)

With most handheld GPS it is only possible to mark locations as waypoints. With the waypoints we
can store attributes. By default it has a Name and a Comment attribute. We will use the Name field
to give a unique code to each feature with a follow-up number. We will use the Comment field to
give a unique name to each specific object. This can then be used to convert the groups of waypoints
to features in QGIS using the Points2One plugin.

41
The table below shows how this works:

Name Note
T01 Tree1
T02 Tree2
T03 Tree3
B01 CityHall
B02 CityHall
These waypoints form one polygon
B03 CityHall
B04 CityHall
B05 House
B06 House
These waypoints form one polygon
B07 House
B08 House
R01 Street1
R02 Street1 These waypoints form one line
R03 Street1
R04 Street2
These waypoints form one line
R05 Street2
 Mark the waypoints of the objects:
 For points you only need 1 waypoint per feature. Give the waypoint a code for points,
e.g. T01, S01. Also give the feature a unique code in Comments, e.g. Tree1, Statue1
 For lines you need multiple waypoints per feature and the number needs to be ordered,
e.g. R01, R02, R03 are 3 points on the line in that order. Also give the feature a unique
code in Comments, e.g. Road1, Road2 or the name of the street.
 For polygons you need multiple waypoints per feature and the number needs to be
ordered, e.g. B01, B02, B03. Also give the feature a unique code in Comments, e.g.
Cityhall, Church, etc.
 Fill in your field form for each feature.

6.4 Importing the GPS data into QGIS


 After getting back from the field, connect the GPS with a USB cable to the laptop.
 When the drivers are correctly installed, the computer will see the GPS as a USB disk. To

access the files choose from the main menu Vector  GPS  GPS Tools or use the
button (make sure the GPS Tools plugin is installed and/or activated).

 In the dialogue choose the tab Load GPX file


 Browse to the GPS and choose the right GPX file from the GPX folder.

42
 Only check the box before Waypoints and click OK to import the data to QGIS
 From the attribute table select the point features and export them as a separate shape
file. Do the same for lines and polygons so you have 3 files, one for points, one for lines
and one for polygons.
 Install the Points2One plugin. This plugin can create lines and polygons from points that
are grouped and sorted.
 Load the Points2One plugin: from the main menu choose Vector  Points2One 
Points2One.

43
 In the dialogue choose the polygon file, select Create polygons, Group features by
comment and Sort vertices by name. Check the box to Add result to canvas.

 Repeat the same steps for the lines


 Evaluate the results.

44
Exercise 4: Map Algebra

45
7 Spatial planning using map algebra

7.1 Learning objectives


After this exercise you will be able to:

 apply map algebra for raster analysis


 distinguish Boolean, discrete and continuous rasters
 make legends for Boolean, discrete and continuous maps
 understand the use of Nodata
 use logical operators
 calculate distances

7.2 Introduction
The Department of Planning of the (imaginary) oasis Aïn Kju Dzjis is planning to build the National
Institute for Oasis Management (NIOM) in their village. They came up with the following conditions
for building the complex:

1 No industry, mine or landfill within 300 meters of the new complex;


2 Not on locations presently in use for buildings, water or roads;
3 The slope should be less than or equal to 3%;
4 The distance from an existing road should be less than 500 meters;
5 The area should be contiguous;
6 The area should be greater than, or equal to 2 hectares.

They hired you as a GIS consultant to find the most appropriate locations. You will use map algebra
to perform the required multicriteria analysis.

7.3 Preparation
 Download the data for Exercise 4 from the OpenCourseWare website
(http://ocw.unesco-ihe.org/course/view.php?id=11) and store the files in a folder on your
harddrive (e.g. D:\QGIS_Exercises\Exercise_4).

In this exercise you will use the following maps: buildg.tif, iswater.tif, isroad.tif,
topo.tif, roads.tif and areamask.shp.

 Preview the maps and metadata of these raster layers by clicking right on the layer file in the
Browser panel and choose Properties.

The Layer properties window will open, showing the metadata of the layer:

46
 Fill in the table:
Layer File type Number of Projection Cell size Minimum Maximum
cells value value
buildg
isroad
iswater
roads
topo
Areamask

 Select buildg.tif, iswater.tif, isroad.tif, topo.tif, roads.tif and


areamask.shp in the browser pannel. Keep the <ctrl> button pressed to select multiple
files. Then click right and choose Add Selected Layers.

47
 Go to the Layers panel and drag the buildg grid to the top in the display tab to view the map
(Note that it is easier if the Layers panel is on top, see figure below.

Rasters normally only store values, so also in this case we need to assign a proper legend to the
map.

 Click right on the name of the layer and choose Properties.

 Click on the Style icon on the left


 Under Render type choose: Singleband pseudocolor
 Under Color use the dropdown menu and choose New color ramp...

48
 Choose Random as color ramp type and click OK
 Choose 6 classes and click OK
 Name it building and click OK

Now fill in the dialogue as follows:


 Mode: Equal interval
 Classes: 6
 Min: 0, Max: 5
 Click Classify

49
 Now use the table below to add the labels to the class numbers. Double click on the label name
to do this. Double click on the colour to make it more intuitive.
0 None
1 House
2 Public
building
3 Landfill
4 Industry
5 Mine

 Click OK to close the dialogue and look at the result. Is buildg a Boolean, discrete or
continuous map?

7.4 Condition 1: No industry, mine or landfill within 300 meters of the new
complex
For condition 1 we have to create a grid with only mines, industry and landfills. Then we have to
calculate the Euclidean distance to these cells. Let’s start with creating a Boolean grid with only
mines, industry and landfills.

50
7.4.1 Create a Boolean grid with True for industry, mine and landfill, and False for other
buildings
 First activate the Processing toolbox by choosing from the menu Processing  Toolbox

 Choose in the processing toolbox


SAGA  Grid - Tools  Reclassify values (simple).

 The Change grid values dialogue appears. We are going to reclassify the buildg raster using a
lookup table. Fill in the dialogue exactly as follows:

51
o Then go to Lookup table and click

o Fill it like the table below. Note that don’t change the second column (High Value),
because the Replace Condition is set to [0] Grid value equals low value. We can use the
second column if we want to reclassify ranges of pixel values.

o Click OK and Run.

 After reclassifying the buildg grid, QGIS will add the new Changed grid to the table of
contents. Rename it to industry by clicking right on the layer name and choose Rename.
 Check the result: 1 for mines, industry and landfills, 0 for the other classes. Use the Identify tool

52
and click on the map. On the panel down left you can find the identify results. It displays
the value of the pixel of the selected layer in the Layers panel. You might have to resize the
columns to see the pixel values.

 Is industry a Boolean, discrete or continuous raster?


 Is the legend that QGIS has assigned automatically correct? Give the industry layer a nice
legend, similar as you did for the buildg layer.

7.4.2 Calculate the Euclidean distance to industry cells


In order to calculate the Euclidean distance from all non-industry cells to industry cells, we need to
change the non-industry cells to nodata. Distance values can only be calculated from a nodata cell to
a data cell. Zero is also data, therefore we need to replace it with nodata.
 In order to change the 0 values in the industry map to nodata we use the Clipper tool. Go in the
menu to Raster  Extraction  Clipper

 Fill in the Clipper dialogue as below. Note that you have to select the areamask from the Mask
layer dropdown list. This vector file contains a polygon of the study area. By selecting 0 as nodata
value, the algorithm will assign No Data to all cells with 0.

53
 Click OK to run the algorithm.
 Click OK, and Close to return to the map canvas. There only view the isindustry map (you can
hide other maps by unchecking the boxes before the maps).
 Check the metadata for the minimum and maximum values of the map. Change the legend.

This map is a special type of Boolean map, because it has nodata and 1.

 The next step is to calculate the Euclidian distance between the pixels with value 1 and other
pixels that have nodata. Select from the menu Raster  Analysis  Proximity (Raster
Distance)….

 Fill in the Proximity (Raster distance) dialogue as below. Name the output map inddist.tif.

54
 Click OK and Close
 Check the result. Is the inddist layer a Boolean, discrete or continuous raster? Make a
legend that is appropriate for this raster type.

7.4.3 Create a Boolean map with True for cells further than 300 meters from industry
and False for other cells
Now we need a map with all the pixels further than 300 meters from mines, industry and
landfills. In the Menu select Raster  Raster calculator... .

 Double click on inddist@1 (@1 means first layer of a stack, but our maps are single layers so
all have only @1), click on the >= button and type 300. Call the output layer noind.tif. The
dialogue should resemble the figure below.

55
 Click OK and view the resulting grid for condition 1. Is the result of condition 1 (noind) Boolean,
discrete or continuous? Give the right legend.

56
7.5 Condition 2: Not on locations presently in use for buildings, water or
roads

 For condition 2 we have to select pixels without buildings, water or roads. First we produce a
Boolean grid with value 1 for locations without buildings. Use the Raster calculator to do this:
"buildg@1" = 0. This results in Boolean true (1) for locations without building and false (0)
for locations with buildings. Call this map nobuild.

 With the raster calculator we search for which pixels have no water and no roads. The pixels
without water can be calculated by the following expression: "iswater@1" = 0
Call this map nowater.

 Do the same for pixels without roads (use the isroad layer). Call it noroad. Check the results.

 Are nobuild, nowater and noroad Boolean, discrete or continuous rasters? Give the right
legend to these layers.

7.6 Condition 3: The slope should be less than or equal to 3%


For condition 3 we have to calculate the slope from the topo grid, which contains elevation
values.

 From the Menu choose: Raster  Analysis  DEM (Terrain Models)…

 Fill in the dialogue like below. Don't forget to choose topo as the DEM Raster, check the box
before Compute edges, choose for Mode Slope and choose Slope expressed as percent (instead of
as degrees). Keep the algorithm as default, call the output slopemap.tif.
Why do we need to compute the edges?
Does this algorithm work with unprojected (lat/lon) coordinates?

57
 Click OK, OK, Close

 Check the result


 Is slopemap a Boolean, discrete or continuous raster? Give the right legend.
 In order to select the slopes less than 3% use the Raster Calculator
("slopemap@1" <= 3). Call the output map nosteep. Is nosteep a Boolean, discrete or
continuous raster? Give the right legend.

7.7 Condition 4: The distance from an existing road should be less than
500 meters
Let’s first describe what we should do, before we perform the GIS analysis. The steps will follow.
Like condition 1, this condition is met by applying the following steps:
1) Creation of a Boolean map with True for tarmac roads and False for other cells
2) Calculation of Euclidean distance from all cells to these roads by:
a. Changing False cells to nodata
b. Calculating the Euclidean distance
c. Creating a Boolean map with True for cells < 500 m from these roads and False for
cells ≥ 500 m from these roads.

First we have to select all the tarmac roads. The table below shows the legend of the roads map.
 Make the legend in the same way as we did for buildg before. Use this table:

58
0 No roads
1 Dirt road
2 Tarmac road

 In this case use the Raster calculator to assign Boolean True (1) for tarmac roads and False (0) for
the rest of the map. Call the map tarmacroad. Check the result. Assign the right legend.

 Now use again the clipper tool (from the main menu choose Raster  Extraction  Clipper) to
assign nodata to the zeros in the tarmacroad layer. Call the result istarmac and check the
result. Assign the right colours to the legend

 Now calculate the distance to a tarmac road like you did before (Raster  Analysis  Proximity
(Raster Distance)…). Call the resulting map tardist. Rename the layer. Check the result.
Assign the right colours to the legend

 To create a grid with only pixels within a distance of 500 meters from tarmac roads, use the
Raster Calculator. The equation should be "tardist@1" < 500. Check the result. Name it
tarzon. Assign the right colours to the legend.

7.8 Combine criteria 1 to 4


 Now all the new maps should be combined to create a grid, which satisfies condition 1 to 4. So all
pixels with value 1 (True) in noind, nobuild, nowater, noroad, nosteep and
tarzon should be selected. Use the Raster Calculator. The dialogue should resemble the figure
below.

 Call the resulting map niomgo and click OK. Check the result carefully and give it the right
legend.

59
7.9 Condition 5: The area should be contiguous
To satisfy condition 5 the groups of pixels must be clustered and then they will get a unique group
number. Then the area must then be calculated for each group. Because Zero values also form a
cluster we need to first change them to nodata.

 Use the clipper tool again to change 0 values to no data in niomgo. Name the result
isniomgo.

The method in GIS to give unique values to each cluster of pixels is called clump.

 In the toolbox click on the r.clump tool (Grass commands  Raster  r.clump).

 Fill in the dialogue that opens as below. Choose isniomgo as Input layer, call the output layer
niomgoclu.tif

 Inspect the result? Is the automatically assigned legend okay? Is niomgoclu a Boolean, discrete
or continuous layer? Assign the correct legend. Rename the layer to niomgoclu.

60
7.10 Condition 6: The area should be greater than, or equal to 2 hectares
Finally, areas greater than 2 hectares can be calculated to satisfy the last condition.
For this last step we have to convert our raster to vector.
1. In the menu choose:
Raster  Conversion  Polygonize (Raster to Vector)…

 Fill in the dialogue as below. Call the output shapefile niompoly.shp.

 Click OK. Click OK, OK, Close to return to the map canvas where the vector layer is displayed.

 Change the vector style of the niompoly layer so it matches with its contents:

61
In order to visualise the polygons larger than 2 ha, we have to do a selection based on this criterion.

 Open the attribute layer of niompoly and click to open the dialogue for selection based
on an expression.
 In the dialogue go to Geometry and double click on $area. Fill in the dialogue as given below
and click Select.

The attribute table now shows 5 selected features. They are also highlighted in the map canvas,
giving the answer to the planning issue.

Export the selected polygons to a new shapefile:


62
 Click right on the niompoly layer name and choose Save as…
 In the dialogue, name the output file selectedloctions.shp and check the box before
Save only selected features.

 Click OK.
 Now hide all layers and only show the selectedlocations layer. Give the layer the right
legend so we can see each location.

 Try by yourself to add a column to the attribute table of the selectedlocations layer and
to calculate the areas of these locations.
 Visualise the end result with a Google satellite image in the background. Use the
QuickMapServices plugin.

63
This whole exercise can be viewed in a screencast
at: https://youtu.be/1Np8nboApfE

8 Inaccessible wells
The Department of Planning of the Aïn Kju Dzjis oasis has consulted you again to report to them
which wells in the oasis are inaccessible for the population. They consider wells that lie more than
150 meters from houses or roads as inaccessible. They provided you with a map with all the wells in
the oasis (wells.tif).

Try to solve this assignment on your own, using the map algebra skills of the previous section. The
result should be a raster layer with TRUE for the inaccessible wells and FALSE for the remaining area.
Besides wells.tif you should also use buildg.tif and isroad.tif. Make a flowchart of
the analysis.

64
Exercise 5: Catchment delineation

65
9 Catchment delineation

9.1 Introduction
In order to delineate a catchment from a DEM we need to follow these steps:

1) Download the DEM tiles of your study area. Make sure that the tiles cover at least the study
area and that the catchment you want to derive is covered completely. Better to take it a bit
larger to avoid boundary effects
2) If your study area is covered by multiple DEM tiles, you need to mosaic (merge) the tiles to
create a single raster DEM layer
3) The DEM tiles might be in a different coordinate system then desired. In that case you have
to reproject the DEM layer to the projection you want to use in the study area
4) In the case that the merged tiles are much larger than your study area, you can subset (clip) it
to a smaller area to reduce calculation time
5) Make a hydrological correct DEM by filling sinks and removing spikes from the raw DEM
6) Calculate the flow direction for each cell
7) Calculate the flow accumulation for each cell: how many upstream cells contribute to the
runoff in each downstream cell of the DEM
8) Derive the drainage network
9) Calculate the catchment for the outflow point of the catchment

When a map with the stream network already exists, the procedure can be improved by "burning"
the river network into the DEM. In that way the DEM is always lower at rivers and runoff will follow
the actual river network. This is out of the scope of this exercise.

This flowchart below summarizes the procedure:

Download Mosaic DEM


Reproject DEM
DEM tiles tiles

Calculate the
Fill sinks /
flow direction Subset DEM
remove spikes
map

Define outflow Derive


Derive streams
point catchment

66
9.2 Download the DEM tiles
For the Rur study area, we will use 4 tiles from the SRTM 1 Arc-Second global data set. The United
States Government announced on September 23 2014 that the highest possible resolution of global
topographic data derived from the SRTM mission will be released to public. Since the end of 2014 a
1-arc second global digital elevation model (30 meters) has been released. Most part of the world
has been covered by this dataset ranging from 54 degrees south to 60 degrees north latitude except
for the Middle East and North Africa area. A description of the SRTM data products can be found
here: https://lta.cr.usgs.gov/SRTM1Arc.

For this exercise the tiles n50_e005_1arc_v3.tif, n50_e006_1arc_v3.tif,


n51_e005_1arc_v3.tif and n51_e006_1arc_v3.tif were already downloaded and
provided. Save the data in e.g. D:\QGIS_Exercises\Exercise_5.

If you want to download data yourself, you can use the USGS EarthExplorer
(http://earthexplorer.usgs.gov).

9.3 Load the DEM tiles in QGIS


1) Start QGIS Desktop.

2) Use the Add Raster Layer button .


3) Browse up to the folder containing the SRTM tiles (e.g.
D:\QGIS_Exercises\Exercise_5). Hold the <Ctrl> button and select the 4 tiles
(n50_e005_1arc_v3.tif, n50_e006_1arc_v3.tif,
n51_e005_1arc_v3.tif and n51_e006_1arc_v3.tif) by left clicking on the tiles.
Click Open.

67
4) You should be able to see this map in the Map Area (as shown below).

We see the four tiles in greyscale. We can distinguish the tiles, because QGIS automatically stretches
the grey values per tile. That means that the grey values are distributed according to the minimum and
maximum value of each tile. When we mosaic (merge) the tiles, QGIS will stretch the values for the
whole area, using the minimum and maximum value of the merged raster layer. You'll see that in the
next section.

68
9.4 Mosaic DEM tiles
Before we proceed, we have to merge the four DEM tiles, which in GIS terminology is called mosaic.
There are two ways to mosaic the tiles:

 Merge the tiles into one physical file


 Merge the tiles into a virtual file

The first option is slower. If we have many tiles, we prefer to make a virtual file that virtually merges
all the tiles. That will be done with the following steps:

1) In the menu choose Raster  Miscellaneous  Build Virtual Raster (Catalog)...

2) In the Build Virtual Raster dialogue you can choose each file individually or merge all files in a
directory (folder). We can also merge the files that are visible in the Map Canvas. We use the
last option:
 Check the box before Use visible raster layers for input.
 Use the Select… button to browse to the location where you want to save the output
file (e.g. D:\QGIS_Exercises\Exercise_5) and give it the name
dem_mosaic.vrt
 Make sure that Load into canvas when finished is checked.

The dialogue should now look like this:

69
3) Click OK to run the algorithm. Click OK, OK, Close to get back to the main screen where you
can see the merged DEM. You notice that in the Map Canvas the borders of the tiles are not
visible anymore in the merged DEM, because QGIS stretches the greyscale using the
minimum and maximum of the entire merged DEM. This is only for visualisation, the values
in the tiles are the same as in the mosaic.

4) Now remove the individual tiles (not the dem_mosaic) from the layers list by selecting
them while the Ctrl button is pressed. Then clicking right one of the tile names and select
Remove. Click OK to confirm. This will remove the tiles from the screen, but not from the
hard disk.

Now your screen looks like this:

70
9.5 Reproject DEM
Before continuing, we need to know the projection of the DEM and reproject it to the projection of
our project.

1) Right click on the layer's name, and select Properties.

2) In the new window select General (the top tab on the left hand-side of the new window).

71
3) In the General window check in the middle, under Coordinate reference system, as shown
below the CRS. Never change the coordinate reference system of the layer here, unless you
are sure what you are doing. It can result in assigning the wrong projection to the layer. This
is not the same as reprojection!

4) The DEM is in its original Lat/Lon Geographic Coordinate System (EPSG: 4326). We need to
convert it into the projection of our project. Because the project covers multiple countries,
we will not use a local projection but a global projection: UTM Zone 32 North, with WGS-84
as datum.
We can find the EPSG codes at http://www.spatialreference.org
Use the website to search for UTM 32N. You can leave QGIS opened and open a browser:

72
5) The database returns:

We have to look at the EPSG codes. We will use the EPSG: 32632 throughout this project. If
you click on it you can see more details.

73
6) Now we are going to reproject the DEM from unprojected (Lat/Lon WGS 84 - EPSG: 4326) to
UTM Zone 32 North / WGS 84 (EPSG: 32632). From the main menu choose Raster 
Projections  Warp (Reproject)

7) In the Warp window, as Input file choose the suggested one (dem_mosaic) and define as
Output file the name dem_reprojected.tif. Use the Select... button to browse to the
right folder (e.g. D:\QGIS_Exercises\Exercise_5)! Click Save to return to the
dialogue.

8) Now complete the dialogue (see screenshot below):


 Check the box for Target SRS. Use the Select... button to select EPSG:32632 from
the dialogue that follows. Type 32632 at Filter and select WGS... EPSG: 32632 in the
middle of the dialogue window and click OK.

74
 Check the No data values box and type -9999. Because the raster
layer will be reprojected there will be "no data" at the borders. In this way we define
that "no data" has a value -9999 and will not be visualised as "data".

Note the gdalwarp command that will be executed in the background.


75
9) Click OK to run. After running click twice OK and close the window. Now you will see that the
re-projected DEM will appear in the list of Layers. The DEM may seem distorted, as shown in
the image below. This is due to the fact that the Map Canvas Projection is still in Lat/Lon, as
testified by the coordinates in the lower part of the Map Canvas. And the EPSG code given in
the lower right corner. This is due to the on-the-fly projection, which causes a difference
between the projection in the file and the one that is visualised.

10) To complete this operation, and display properly the new dataset, we need to change the
on-the-fly projection of the Project. To do so click on the EPSG: 4326 (OTF) in the lower right
of the screen.

11) In the new dialogue window select the EPSG:32632 projection that is already in the list of
Recently used coordinate reference systems, as shown below, and click OK.

In the Map area the DEM is now displayed in the correct position (with the North pointing up),
as shown below. The coordinates of the new display are also in meters as we want.

76
North up

12) You can now remove the file dem_mosaic by right clicking on it and choosing Remove. Click
OK to confirm.

9.6 Subset DEM


In order to reduce the calculation time of the algorithms, we will subset (or clip) the raster layer.

An easy way to select the boundary of your study area (always make it a little bit bigger to prevent
boundary effects) is to use OpenStreetMap. OpenStreetMap contains crowd sourced data (see
http://www.openstreetmap.org for more info). If the QuickMapServices plugin is installed, you can
add an OpenStreetMap to QGIS as follows:

1) In the menu choose Web  QuickMapServices  OSM  OSM Standard

77
2) Now an OpenStreetMap will be shown in the Map area.

3) In order to know the approximate extent of the Rur catchment, the exercise data contains a
shapefile with the sources and the mouth of the catchment. Open the vector layer
source_mouth.shp

4) Now, from the Main Menu select Raster  Extraction  Clipper as shown below:

5) Then from the new dialogue window you can decide on the new raster name (here we use
dem_subset.tif). Use the Select... button to browse to the right location (e.g.
D:\QGIS_Exercises\Exercise_5).

6) Then draw on the Map Area the extent that you want to clip the raster to. A red rectangle
will appear. It should be similar to the one below, around the 3 points in the shapefile. Click
OK in the Clipper dialogue window and dem_subset will appear. Note that if you make it

78
too large, the calculation time will be too large, if you make it too small, your catchment
might not fit within the choosen area and has square borders.

7) Now you can remove dem_reprojected from the layers list as we have done before for
other layers that are not longer needed.

9.7 Fill sinks / remove spikes


Raw, unprocessed DEMs have artefacts such as depressions and peaks. These artefacts are a result of
the DEM acquisition process and need to be removed before a DEM can be used for hydrological
analysis, like catchment and stream delineation or hydrological modelling. There are several
algorithms for filling sinks. Here we will use the algorithm developed by Wang and Liu (2006), which
is faster than other algorithms and therefore works better with high resolution datasets.

1) We will use the QGIS Processing Toolbox. If you don't see the Processing Toolbox at the right
of your screen, you can enable it by choosing from the main menu Processing Toolbox

79
2) In the Processing Toolbox use the Search... field to search for fill sinks

3) Go to SAGA  Terrain Analysis - Hydrology  Fill sinks (wang & liu). You see that there
are more algorithms for filling sinks. Each has its own advantages and disadvantages in terms
of calculation time, memory usage and accuracy. For your own research you need to make a
decision based on the documentation of the algorithms or by analysing the results of several
algorithms.
4) In the dialogue keep the defaults. Make sure to select dem_subset as the input and define
dem_fill.tif as the Filled DEM. Always use the button and Save to file... to
browse to the right location (e.g. D:\QGIS_Course\Exercise_5). We only need the
Filled DEM at this point, so you can uncheck the boxes for opening the output of Flow
Directions and Watershed Basins. The dialogue should look like this:

5) Now remove dem_subset from the layers list, because it is no longer needed.

80
9.8 Calculate Strahler order and determine threshold for streams
Before we can derive the streams from the DEM, we need to determine what we consider streams.
For this purpose we use the Strahler order. The higher the order, the bigger the stream.

1) Search for Strahler in the Processing Toolbox and select


SAGA  Terrain Analysis - Channels  Strahler order

2) In the dialogue select the Filled DEM for the elevation. And use strahler.tif as the
output filename and click Run.

3) Check the result. What are the minimum and maximum values? Is the Strahler raster discreet
or continuous? Make a nice legend, where the highest Strahler orders are more blue so you
can clearer see what the rivers are.

81
4) Use the Raster Calculator to create a Boolean map with 1 for Strahler order >= 5 and 0 for
the other values. Call the output file strahler5.tif

5) Make a nice legend where 1 is blue and 0 is transparent. Check the result with the rivers in
OpenStreetMap.
6) Repeat steps 4 and 5 with different threshold values and choose the best result.

9.9 Calculate flow direction, channel network and catchments


Now with our corrected DEM and the threshold value (Strahler order) we can proceed to calculate
the flow direction, channel network and catchments in our area. We will use the D8 method for flow
direction. The D8 method evaluates the slopes in 8 discrete directions around a pixel.

In the Processing Toolbox you can also find related tools that use different algorithms. Always check
the documentation of the algorithm to find the right one or do a comparative analysis.

1) Search for Channel in the Processing Toolbox and select


SAGA  Terrain Analysis - Channels  Channel network and drainage basins

82
2) In the dialogue select the Filled DEM for the elevation and put the threshold at the value
you found in step 6 of the previous section, e.g. 8). This means that streams with a Strahler
order larger than or equal to this value will be considered as rivers. The algorithm will
calculate flow direction and the Strahler order to determine the channels and drainage
basins.
Select the checkboxes for the following outputs:
 Flow direction and save it as flowdir.tif
 Channels and save it as channels.shp.
 Drainage basins and save it as basins.shp (the other one is for raster)

Always use the button and Save to file... to browse to the right location (e.g.
D:\QGIS_Exercises\Exercise_5). If the dialogue is similar as below, click Run.

83
3) Inspect the results. Make legends for all these maps (are they discrete, continuous or
Boolean?).
 What does the Drainage Basins map show? Does it already give a good indication of
the Rur catchment?
 What does the Flow Direction map show? What does the legend mean? Make a nice
legend using styling.
 Does the stream delineation map (channels) reflect well the flowline of the Rur
river? Drag it to the top of the layers list and give it an intuitive style. Overlay the
Channels vector on OpenStreetMap to see if the derived streams fit with the rivers
on the map (make them different than blue to see the difference with the map.
What went well? What went wrong? Why?

9.10 Define outflow point


A catchment is an extent or an area of land where surface water from rain, melting snow, or ice
converges to a single point at a lower elevation, usually the exit of the basin, where the waters join
another water body, such as a river, lake, reservoir, estuary, wetland, sea, or ocean. In order to
delineate a catchment we need to have two fundamental data:
84
 the coordinates of our outlet in the same coordinate system as the map we are using
 the channel network that matches the flow directions as calculated from a hydrological
correct DEM

The outflow point of the Rur catchment is in Roermond an can be found in the given shapefile
source_mouth.shp . The channel network that has been derived is in channels.shp .

1) Make sure you have the channels.shp layer on top of the OpenStreetMap layer from the
QuickMapServices plugin.
2) Check that the source_mouth.shp (1) has the same projection as channels.shp, and
(2) that the outflow point is located exactly overlapping the delineated river in
channels.shp. If the outflow point is not exactly over the delineated river, the catchment
will not be delineated. In that case we need to look for a location over the delineated
channels as in this example:

Note that there has been some distortion for 3 reasons:


 Incorrect automatic delineation of streams, which can be caused by errors in the
DEM or areas that are too flat
 Distortion due to on-the-fly reprojection
 Human influence on the natural course of the channels

85
3) Now use the coordinate capture tool to get the coordinates of the outflowpoint in
channels.shp. You can find the coordinate capture tool from the menu: Vector 
Coordinate capture  Coordinate capture. Or look for this icon in the icon panel on the left

of the screen: . Note that the plugin needs to be installed and activated (check the box
in the Plugins Manager). Another panel will show up:

4) Click on Start capture and click on a point on the delineated river close to the mouth of the
Rur as indicated in the figure. Make sure you capture it from the river in channels.shp,
because the background map (OpenStreetMap) has not been derived from the DEM and will
result in errors in the catchment delineation. What projection are we using? How do you
know?

9.11 Delineate catchment


Now we're going to use these coordinates to calculate the upstream area that produces discharge at
this point.

1) In the Processing Toolbox search for Upslope Area and choose SAGA  Terrain
Analysis - Hydrology  Upslope Area

86
2) Fill in the dialogue as below. Use the coordinates that you captured near the outflow point.
For elevation use your filled DEM. Use the default D8 method. Name the output
Rur_catchment.tif. Click Run.

87
The result should look like the screenshot below.

3) In order to overlay the catchment boundary with other data, it is better to convert it from
raster to vector (polygon). To convert the raster layer to vector, go to the menu and choose
Raster  Conversion  Polygonize (Raster to vector). Make sure you choose the right input
and call the output Rur_catchment.shp. Click OK to run. Click OK, OK, Close to get back
to the main screen.

88
4) Look at the result. Also check the attribute table (Click right on layer name catchment 
Open attribute table). What value has the inside of the catchment polygon? What
value has the outside area?
5) Of course we are only interested in the catchment area, so we have to remove the outside
polygon. In the attribute table toggle to editing mode by using this button: . Then select
the record that you want to remove. The selection will be highlighted in yellow on the map.
Then click to delete the selected feature and toggle off the editing by clicking again
and save the changes.

6) Now remove all unnecessary layers from the layers list so that we have only
Source_mouth, Channels, Rur_catchment, OSM Standard and Filled DEM
(in that order).

89
7) We can clip the Channels vector layer to see only the streams that are inside the
catchment. Go to the menu and select Vector  Geoprocessing Tools  Clip.

8) Fill in the dialogue as below to use the catchment layer as a "cookie cutter" to clip the
channels shape file to the catchment extent. Call the output channels_clip.shp. Click
OK to run the tool. Click Close to return the main screen.

90
9) Remove Channels form the layers list and drag channels_clip to the top of the list.
10) Give channels_clip an intuitive colour and make the Rur_catchment polygon
hollow (no fill colour) and give it a thick red border. You can do this by clicking right on the
layer name, selecting Properties... and go to the Style tab. You can also press <F7> to open
the styling dock and set the styling options for different layers from there.

91
The result should be similar to this:

11) At this point save your project. Choose from the main menu Project  Save as...

12) In the dialogue that follows, browse to D:\QGIS_Exercises\Exercise_5 and save


your project as Exercise_5.qgs

92
Now try to calculate slope, aspect and hillshade using the functions in the menu
Raster  Analysis  DEM (Terrain Models) or the processing toolbox and make some nice maps
with good legends.

This whole exercise can be viewed in a screencast


at: https://youtu.be/uSscn6ImRxU

93
Exercise 6: Using Open Access Data

94
10 Using Open Access data

10.1 Introduction
Now that we have defined the boundaries of our study area, i.e. the Rur catchment, we can look for
open access data that is available on the internet. In this exercise we will use

 Data from the European Environment Agency (EEA) public map services:
http://discomap.eea.europa.eu
 Data from OpenStreetMap: http://www.openstreetmap.org

Instead of using a web browser, we will create a live link between the online data and our data in
QGIS, using Web Map Services (WMS), which is an open standard for sharing maps through the
internet and we will also download vector layers from OpenStreetMap through QGIS.

For this exercise you need the delineation of the Rur catchment and its streams from the previous
exercise. You can also download them from the Open Courseware website (http://ocw.unesco-
ihe.org).

Before we start, make sure that you have the following layers on your screen:

 Boundary of the Rur catchment


 Streams in the Rur catchment
 OSM Standard backdrop from the QuickMapServices

Your screen looks now like this:

95
10.2 Adding data from the European Environment Agency (EEA) public map
services
The European Environment Agency (EEA) is the agency of the European Union (EU) that provides
independent information on the environment, thereby helping those involved in developing,
adopting, implementing and evaluating environmental policy, as well as informing the general public.
The European Environment Agency provides maps on thematic areas such as air, water, climate
change, biodiversity, land and noise. The map services are accessible through
http://discomap.eea.europa.eu. In this exercise we will add data from the EEA public map services to
our QGIS project.

1) Go to the website http://discomap.eea.europa.eu. There you see a list of themes.


2) Click on Land under Land. Here you can see the EEA datasets related to land cover and their
descriptions.
3) Look for the Corine Land Cover 2006 – v17 data and click on More info to see what data it
contains.
4) Click on the picture of the map on the left to open an interactive map viewer
5) In the map viewer click on the Legend tab and zoom in at the study area.

6) Now we're going to add this land-cover data to our QGIS project. Go to your QGIS project.
From the main menu choose Layer  Add Layer  Add WMS/WMTS Layer... or use the
button from the toolbar on the left of the screen.

96
7) In the dialogue that opens click the New button.
8) In the dialogue that follows type for Name: EEA Land
9) We can find the URL on the website: below the title of the Corine Land Cover 2006 – v17
(MapServer) click on WMS

10) A page with XML code opens. Copy the URL of the page until the question mark:
http://land.discomap.eea.europa.eu/arcgis/services/Land/CLC2006
_Dyna_WM/MapServer/WMSServer?

97
11) Paste the link in the QGIS dialogue (see screenshot below), keep the defaults and click OK.

12) Back in the other dialogue window click Connect. The layers will now be retrieved from the
WMS server

13) Click on Wetlands so that it is highlighted, choose PNG for the Image encoding format (this
allows transparency) and check the box before Use contextual WMS legend. Then click Add
and Close to return to the main screen. Note that WMS layers are georeferenced pictures,
not vectors.

98
 You can see that the source area of the Rur catchment is located in wetlands. What
are the names of these wetlands?
 In which country/countries are these wetlands?

14) Now add in a similar way Artificial Surfaces.

 In the midstream part of the catchment there are some large purple areas. What are
these?
 Add Google satellite from the QuickMapServices to have a closer look at these
features. Describe what you see.
 What are the other Artificial Surface classes in the map? Can you describe the
geographical distribution of population in the Rur catchment?
 What are the largest cities in the catchment?

15) Load the remaining classes.


 Where are the forests and agricultural areas located?

16) Now rearrange the layers as such that you have a map with the catchment boundary, stream
network and land cover classes.

99
17) Save the project before you continue.

If you have time, you can look for more EEA data in a similar way.

100
10.3 Adding vector data from OpenStreetMap
OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world. OSM is
considered a prominent example of volunteered geographic information (VGI) or crowdsourcing.
There are several ways to use the data:

 Through the interactive map on the OpenStreetMap website


(http://www.openstreetmap.org)
 In QGIS through the QuickMapServices Plugin
 In QGIS through the option to download OSM data directly from the internet.

In this exercise we are going to download OSM vector data directly in QGIS for the city of Jülich.

1) Try to locate Jülich. You can also use the GeoCoding plugin to locate Jülich. You can install it
through the menu: Plugins  Manage and Install Plugins… . Search for GeoCoding. The
GeoCoding plugin uses web services (Nominatim and Google) to retrieve the coordinates of
an address. A popup window will ask for a projection so QGIS can show the point on the right
spot in the Map Canvas. It doesn’t matter which projection you choose, because QGIS will
on-the-fly reproject the point to the projection of your project.
2) Now zoom in on the centre of Jülich (see figure below).

Southeast of Jülich is the Forschungszentrum Jülich, a large research institute. In the south
and east we see a large surface mining of lignite. The one in the south is in the Rur
catchment.
3) Now compare the OSM Standard backdrop with a Google Satellite and the EEA artificial
surfaces map. What are the differences? Which one is more up-to-date? EEA or OSM?
4) The OSM Standard backdrop is just a picture that is not useful for vector based GIS analysis.
Therefore, we are going to download now all OSM vector data into QGIS. In the menu go to
Vector  OpenStreetMap  Download Data…
101
5) In the dialogue choose From Map Canvas. Then all data within the extent on the screen will
be downloaded. Save the file as Julich.osm in e.g.
D:\QGIS_Exercises\Exercise_6. Click OK and Close the dialogue after the message
that the download has been successful.

6) Now choose from the same menu Vector  OpenStreetMap  Import Topology from XML…
7) Fill in the dialogue as below and click OK.

8) After running click OK and Close. Now the OSM xml data has been loaded into a SpatiaLite
spatial database.
9) Now we have to make layers in the database. From the same menu now choose: Vector 
OpenStreetMap  Export Topology to SpatiaLite…
10) We’ll now make a layer with land-use polygons. Choose Julich.osm.db as the Input DB
file. Choose Polygons as the Export type. Change the Output layer name to
Julich_landuse. Click Load from DB and check the box before landuse. The dialogue

102
should now look like this:

Click OK to run. Click OK and Close to return to the map canvas.

11) The layer is now automatically loaded from the database. You can later always access the

layer by adding a SpatiaLite layer by clicking the button.

12) The land-use polygons in the SpatiaLite DB also have attributes like a shapefile. Open the
attribute table (click right on the layer name and select Open Attribute Table).
103
13) Let’s make a new layer with only the mines. We need to select those features using an
expression. Click this button to do so .
14) In the Select by expression dialogue that opens, expand Fields and Values and double click on
landuse.
15) Click the button all unique to load all unique values.
16) Click the = sign and double click ‘quarry’:

If the dialogue looks like this, click Select and Close.


In the title of the attribute table you can see that 10 polygons have been selected. In the map
canvas they are shown in yellow:

104
17) Save the quarry polygons as a shapefile: click right on the layer, choose Save as…
18) In the dialogue, save the file as quarries.shp in the right folder using the Browse button.
Select the right projection and check the box to Save only selected features. The dialogue
should look like this:

Click OK to save the shapefile.


19) Check if all quarry polygons can also be identified on the Google satellite image. Is the Open
Streetmap data older or newer than the satellite image? How is the delineated hydrography
affected by the quarries?

105
11 Create 2D and 2.5D maps

11.1 Introduction
With the GIS data collected in the previous exercises, we are now ready to produce some maps to
take with us in the field. In this exercise we will produce two types of maps:

 A PDF map with coordinate grid, north arrow, scale bar and legend (2D)
 An interactive 2.5D map to visualise the layers draped over the DEM

You can make maps through combination of layers that we have collected in the previous exercises.

11.2 Creating a PDF map


1) First arrange the layers on the screen in such a way that all layers you want to have in the
map are visible and at the right zoom level. Also verify that the on-the-fly projection is
EPSG:32632.
2) Configure the right styling of the layers. Remember to use intuitive colours.
3) Use the Print Composer (Project  New Print Composer) to create a map with all its
properties (North arrow, scale bar, intuitive legend, etc.). Use the instruction video on
eCampus. When finished choose from the menu Composer Export as PDF...

106
11.3 Creating a 2.5D interactive map
We can drape GIS layers over a DEM and create a 2.5D interactive map.

1) Please make sure you have the Qgis2threejs plugin installed. If not, in the main menu go to
Plugins  Manage and Install Plugins... and install or activate the Qgis2threejs plugin.

2) Now configure the layers on the screen as you want them to be shown in 2.5D, e.g.:

3) Open the plugin dialogue. In the main menu go to Web  Qgis2threejs  Qgis2threejs or
use the button.

107
4) Under World, change the Vertical exaggeration to 5:

5) Under DEM make sure that the DEM layer is selected (e.g. Filled DEM) and move the
Resampling slider completely to the right for maximum detail. Check the box Enable shading
for a more realistic effect:

108
6) Click Run. The plugin will open the browser with your 2.5D draped interactive map.

11.4 Export to Google Earth

7) You can also export files to Google Earth. To export the catchment delineation to Google
Earth do the following: click right on the Rur_catchment layer and select Save as...
8) In the dialogue select Keyhole Markup Language [KML] as the output format. Choose an
output filename and click OK. The resulting file can be opened in Google Earth by double
clicking on the filename in Windows Explorer.

Note that the CRS does not matter. A KML file will always be saved in the projection that is
supported by Google Earth.

109
Exercise 7: Map design

110
12 Styling and map design

12.1 Introduction
After this exercise you will be able to:

 Style vector layers


 Copy, import and export styles
 Design a map

In this exercise we are going to add mainly vector data related to water supply. The exercise encloses
the styling of various vector layers and designing of a map with various map item in the print
composer.

In this exercise we'll use the following data:

 Area.shp (and associated files): polygon of the area of interest


 Endcap.shp (and associated files): points of the endcaps
 Household_connection.shp (and associated files): points of house hold
connections
 Hydrants.shp (and associated files): points of the hydrants
 Pipeline.shp (and associated files): lines of the pipelines for the water
supply
 Source.shp (and associated files): points of the sources of water
 Tanks.shp (and associated files): points of storage tanks for water

The dataset has been developed by Vitens Evides International and the National Water and Sewerage
Corporation in Uganda.

2. Download the data for Exercise 7 from the OpenCourseWare website


(http://ocw.unesco-ihe.org/course/view.php?id=11) and store the files in a folder on your
harddrive (e.g. D:\QGIS_Exercises\Exercise_7).

This exercise will guide you through the following steps:

 Style the shapefiles;


 Save the styles;
 Set the layout of the final map in the print composer.

111
12.2 Style vector data
1. Start QGIS Desktop.
2. Add the vector layers (shapefiles) of this exercise to the map canvas. What is the projection
of these files?
3. As a background, a satellite image can be used from the QuickMapServices Plugin. In the
menu choose Web  QuickMapServices  Google  Google Satellite.

4. Place the shapefiles and the Google Satellite image in a useful order by dragging the items in
the layers list. For example, background images are normally the lowest layers.
5. We now start with styling the vector layers. Each layer is appointed a random style when you
open it. Styling covers the colours, shapes, sizes, text labels. The styling is done under the
properties of each layer (right-click on layer). Now choose Household_connection 
properties  Style.

112
6. For the household connections a red cross will be the symbol to use. In order to do so select
simple marker  cross symbol. The colour of the outline should be a red colour.

7. You can enter for the size 20 map unit and for the width 3.0 map unit. You can choose
between mm and map units. For millimetres the zooming level does not matter and the
symbol always stays the same size, even if you zoom in very closely. When selecting map
units, the symbol becomes bigger when you zoom in.

8. Click OK to close the dialogue and return to the map canvas.

9. Open the attribute table of the ‘Pipeline’. Do this by clicking right on the layer and choosing
Open Attribute Table. Investigate the type of information that is there.

113
10. Now style the ‘Pipeline’ shapefile by opening its properties. Instead of a Single Symbol, select
the Categorized. In the map, there needs to be a distinction between the transmission lines
and the distribution lines. In order to do so, which column do we need to select to categorize
on?

11. After the selection of the correct column, click Classify. You will find two new symbols for
‘Transmission’ and ‘Distribution’. By double clicking on the lines you can modify the style.
12. Choose an appropriate style according to your own insight. Just to remind you – use the map
unit for the width of the line. After finishing the styling of the two layers, click Apply.
13. The map should also indicate the type of material and the width of the pipeline by not using
anymore colours. For that we use text label, which you can also find in the Layer Properties
tab on the left side. Choose from the dropdown menu Show labels for this layer. Now you
can select a column using the drop down list at Label with.
14. If you want multiple columns in the label, you can enter an expression, which is next to the
arrow. Click the button to enter the following expression: "Material o" || ' - ' ||
"Diameter o" || ' mm'
 The text between double quotation marks (“) indicate the column.
The text between single apostrophe (‘) is a text of string.
 The double vertical bars (||) are necessary to have multiple strings next to each
other.
 If the preview looks okay, click OK

114
15. The default text is not yet appropriate. To change this you find a lot of options below the
‘Lorem Ipsum’, which shows an example of how the text will look.
 Under TEXT - For font use Tahoma, for size use 10 points, for colour choose blue.
 Under Buffer - For Size use 1 mm
 Under Placement – Choose curved, for position untick ‘Above line’ and tick ‘On line’
 Press OK

16. For the ‘Source’ and the ‘Tanks’ layers, the following two symbols will be created:

115
These are basically two simple markers. Here the marker for the ‘Source’ layer will be
discussed.
17. Open Properties  Style and Add a symbol layer . Both simple markers should be a
circle. For the top circle:
Make border transparent
Set colour to red
Set size to 20 map units

For the lower circle:

Make border transparent


Set colour to white
Set size to 30 map units

116
18. Make a similar symbol for the ‘Tanks’ layer as shown in step 16. We can easily do this by
copying the style and modifying it. To copy the style of ‘Source’ click right on the layer name
and select Styles  Copy Style.

19. Now click right on the ‘Tanks’ layer name and select Styles  Paste Style.
20. You can now modify the style of the Tanks layer in the Styles dialogue similar to step 18.
21. Design your own symbol for the ‘End points’ layer with a label to identify the ID.
22. The background satellite image is too dominant. We can make it transparent. Click right on
Google Satellite and choose Properties. Set the transparency to 40%.

23. Lastly the style of the ‘Area’ polygon layer will be set. Open Properties  Style tab  add
symbol layer (the + sign). For the top symbol layer choose the following specifics:
Fill is transparent
Outline is grey
Outline width is 2 mm
For the bottom symbol layer choose the following specifics:
Symbol layer type is Shapeburst fill
Change the gradient colours to grey and white with 50% opacity
Shade to set a distance to 5mm.
24. Lastly change from ‘Single Symbol’ to ‘Inverted polygons’. This actually means that you are
styling everything outside the selected polygon and click OK

117
The result now looks like this:

12.3 Saving and exporting layer styles


Layer styles are not stored in the GIS files (e.g. shapefile or GeoTiff). They can be stored in your
project file (a .qgs file), together with the zoom level, on-the-fly projection, etc.

1. Save the project as Adjumani.qgs. In the menu choose: Project  Save as… and save the
file to the correct folder.

If you don’t want to share an entire QGIS project, but just a layer with its styling, you’ll have to save
the styling to a file. Similar to an ArcGIS Layer file (.lyr) QGIS has its own format, the Layer

118
Definition File (.qlr). Please note that these are software specific xml files and not international
standards that allow for interoperability among software. For interoperability, it is better to use the
Styled Layer Descriptor (SLD) file. SLD’s are also used to style online maps.

Let’s save the styles of the layers in this project to .sld files.

2. Go back to the Styles dialogue and select Style  Save Style  SLD File…

If you would now start a new project and you add a layer, you can also load a saved style from
the .sld file. Also if you would upload a shapefile to GeoServer, you can use the .sld file to
style the online map.

12.4 Make a map in the print composer


1. Create under Project  New Print Composer a new layout and give it an appropriate name.

2. Normally, you need to design a map layout before you start to make the map, this means
that you already know the general set up of the map and the various items you want to show
on the map.

119
3. To set up the print composer, you need to choose which paper size you want to use (A3/A4
etc.) under Composition. The export DPI (dots per inch) is important for the quality of the
map. With more dots per inch, you will get a higher quality (and larger size) export product. A
DPI of 300 is appropriate for now. You can also choose between ‘Landscape’ vs ‘Portrait’
according to your needs
4. Click ‘Add a map’ and click and drag to make a map.
Under Item properties, you can edit the position on the canvas and zoom in. Find an area of

interest to you. You can also use Move item content .


5. As you are now zoomed in to a part of the city in the map, a small overview map makes it
easier to orientate yourself. Again click ‘Add a map’ and drag a smaller map. (If you hold
shift, it will become perfectly rectangular. Zoom until you have the whole area in the
overview map.
6. To create an overview select the tab Item properties. Under Overviews click the + sign to add
an overview. Select for ‘Map Frame’ Map 0. You can edit the color, transparency and even
make it inverse. Choose yourself.

7. Now you will see every layer in the overview map, but we can remove some detail to make it
easier to understand. Go back to the Map Canvas of QGIS and untick every layer except
‘Area’.

120
8. Go back to the Print Composer and Select the overview map. Under its Item Properties 
Tick Lock Layer for this Map. Click Update preview. Now it will only use the ‘Area’ shapefile
to draw the map and it will be fixed if you tick the layers back on for the larger detailed map.
9. Below you find an overview to add other items.
NOTE: under properties you will find many options per item. The default is often not the one
you want.
10. Do not forget to save the project file (.QGS) once in a while.

11. Now add north arrows logos scale bars legends (sub)titles . to your
choosing. The logo’s and north arrows are in the folder ‘Exercise Map Design\Images’. Be
creative!
12. After finishing the map with your satisfaction, export the map to a pdf or an image .

Export to an image format, to PDF or to SVG

Zoom to full extent, in and out

Refresh view

Revert and restore last change

Add new map from QGIS map canvas

Add image to print composition (images such as logo, north


arrow)

Add label to print composition ( text such as (sub)titles or


abstract)

Add new legend to print composition

Add new scalebar to print composition

Add basic shape to print composition

Add arrow to print composition

Move content within an item (move within a map to redefine the


x, y and scale)

Group items of print composition and Ungroup

Raise/Lower selected items

Move selected items to top/bottom

Align selected items left / right center / center vertical / top /


bottom

121
122
References
Wang, L. and Liu, H., 2006. An efficient method for identifying and filling surface depressions in
digital elevation models for hydrologic analysis and modelling. International Journal of Geographical
Information Science, 20(2).

Links
EPSG codes: http://www.spatialreference.org

European Environmental Agency Public Map Service: http://discomap.eea.europa.eu

OpenStreetMap: http://www.openstreetmap.org

QGIS: http://www.qgis.org/

SRTM data description: https://lta.cr.usgs.gov/SRTM1Arc

USGS EarthExplorer: http://earthexplorer.usgs.gov

Screencasts
Screencasts can be found in the following YouTube channel:
http://www.youtube.com/c/HansvanderKwast

123

You might also like