Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Practical Exercise 4 & 5: Projections and mapping (QGIS)

Table of Contents
Introduction ........................................................................................................................... 1

Pre-Practical task: videos ...................................................................................................... 2

Study Goals .......................................................................................................................... 2

Data ...................................................................................................................................... 2

1. Task 1: Basics of styling vector layers ............................................................................ 3

1.1. Open a project and re-project data.......................................................................... 3

1.2. Adjust styles (symbols, colours and presentation) ................................................... 6

1.3. Adding Labels ....................................................................................................... 11

2. Task 2: Calculate area and a graduated symbol display .............................................. 14

2.1. Calculate Geometry .............................................................................................. 14

2.2. Graduated symbols ............................................................................................... 16

3. Task 3: Create a map layout ........................................................................................ 18

4. Task 4: Export the map to an image (JPEG Format) .................................................... 36

5. Task 5: Add graphic to an A4 Word/Pdf document: ...................................................... 36

6. Task 6: Map submission .............................................................................................. 37

Special acknowledgement: ................................................................................................. 37

Introduction
To create a map, one has to style the GIS data display and present it in a form that is visually
informative. There are a large number of options available in QGIS to apply different types of
symbology to the underlying data. In this practical, we will re-project the data as used in
Practical 3 and apply some of the basic styling and mapping layout tools.

1
Pre-Practical task: videos
Watch the following videos on clickUP (Videos→QGIS videos) on how to use the Map
Layout (Print Composer) in QGIS before attempting this practical exercise:

 Print layout in QGIS


 Adding a basemap in QGIS
 Creating a map

Study Goals
After completing these practical tasks, you should be able to:
i. Know how you can check or set the coordinate system for a new project.
ii. Show that you can project or re-project data to a different map projection.
iii. Adjust the symbology of data layers for a suitable map layout.
iv. Create a suitable map layout.
v. Save the map layout to a Jpeg or Pdf file format.
vi. Submit the map layout on ClickUP in the correct Assignment tab.

Data
The data used in this exercise is the same Malawi data as we used in Practical 3, but this time
we will only use the vector data layers. Reminder: The vector data layers were downloaded
from OpenStreetMap (OSM).

The data used in this practical is available under Practical data → Malawi data

Data layer Data type Description


Malawi_Boundary Vector Polygon Malawi boundary/polygon
Malawi_Places Vector Points Places (Cities, towns) in Malawi
Malawi_Rivers Vector Lines Rivers in Malawi
Malawi_Water Vector Polygons Water bodies in Malawi

2
1. Task 1: Basics of styling vector layers
1.1. Open a project and re-project data
1.1.1. Open QGIS Desktop.
1.1.2. Open a NEW project for a new mapping exercise.

1.1.3. The Malawi data has a Geographic Coordinate System assigned but is not projected.
If you want to create buffers around features or measure areas, you will have to project the
data. In such cases you will decide on a suitable projection for your project and then set it
in project properties. E.g., For this project we will set the projection for the new project to
the World Mercator projection which is fine for the region that we will be mapping.
1.1.4. Select Project→Properties – CRS and then search for and select WGS / World
Mercator EPSG: 3395 - click OK.

1.1.5. SAVE your project with a descriptive name (e.g. P4_5_Malawi_Map)


Make sure to keep saving the project as you work so you do not lose your work
should QGIS crash or stop working.
1.1.6. Add the required vector layers your map.
 Malawi_Boundary
 Malawi_Places
 Malawi_Rivers
 Malawi_Water

3
1.1.7. Now you can re-project the layers (all four) to the projection system (CRS) that you
chose. You can do this by using the data management tools in the GIS, e.g.

 Search for and select WGS / World


Mercator EPSG:3395

 Save the layer in your data folder


to file with an appropriate name
(e.g. Malawi_Boundary_Projected)

 Click Run

Note: In GIS it is important to have


all your layers in a similar coordinate
system – especially if you plan on
using any analysis procedures.

1.1.8. It is possible to re-project all four layers at the same time instead of one at a time by
running the reproject tool as a batch process.

E.g. Click on “Run as Batch Process” to open the batch processing window.

4
Select all the layers you want
to reproject using “Select from
Open Layers”

Save each layer in your data folder


Search for and select WGS /
to file with an appropriate name
World Mercator EPSG:3395
(e.g. Malawi_Boundary_Projected).
for each layer

1.1.9. NB! Remove the old layers from your project and leave only the re-projected layers.

5
1.2. Adjust styles (symbols, colours and presentation)
Once you have all the layers that you need, you can start to style them appropriately and add
some labels.

Note: Make sure the colours are appropriate (e.g. not too similar or too dominant), and that
the symbols are distinctive and add labels where appropriate, e.g.

1.2.1. To change the colour of the Malawi boundary layer – One will use the layer properties
and the symbology tab: You can change the colour, or even make it hollow and set the
thickness of the boundary, etc.
1.2.2. Right click on the Malawi_Boundary layer  Select Properties

1.2.3. In order to style a layer, activate Symbology in the Properties dialog.


1.2.4. The various styling options are located in the Symbology tab of the Properties dialog:

The default style is a Single Symbol. Clicking on the drop-down button in the
Symbology dialog, you will see there are seven options available – No symbols,
Single Symbol, Categorized, Graduated, Rule Based and Inverted polygons and
2.5D. We will explore the first three options: Single Symbol, Categorized and
Graduated in this practical.

6
1.2.5. Modify style: Single Symbol.
The single symbol option allows you to choose a single style that will be applied to all
the features in the layer. The Malawi Boundary is a vector polygon dataset and there
are several choices. For now, we will explore a few basic ones:
a) You can modify the interior (fill) of the polygon (Note: Select Simple fill)
 You can select a solid colour to fill the polygon.

Note: Similarly, the colour of the water features can be changed to a blue colour.

b) You can adjust the outline (Stroke colour, width, style, etc.)
c) Or you can style with a hollow interior.
 Change the fill style to No Brush (to remove the colour)

7
1.2.6. We have explored the Single Symbol symbology type, let us explore the
Categorised symbology type now.
To display the type of features based on information in the attribute table, you can choose a
field to categorize the features on and use different symbols to differentiate between the
features, e.g.
a) If you open Malawi_Places attribute table, you will notice there are different classes
of places (Class field/column), namely, city, national capital and town.

b) So in the Malawi_Places layer, you can use the “Class” field to distinguish between
the Capital City, cities and towns in the Places data layer. You can use different
colours, or different sized symbols or even different symbols.

8
Note: When you look at the symbols in the map view, they all look the same (same colour,
same shape) so you cannot differentiate which ones are cities, national capital or towns
because they are currently represented as Single Symbols. To modify this:

a) Open the properties for Malawi_Places.


b) The default style is also a Single Symbol. However, you now know that Single Symbol
is not useful in showing the different classes or types of places. Let us try a different
styling option.
 Clicking on the drop-down button and Select Categorized from the
available options.
 Choose Class value as the column.
 Choose a color ramp of your choice.
 Click classify at the bottom.
This will show you the different classes and the colours that will be used
to represent them.

c) You can also add or remove classes. For instace, if you want to remove the last class in

the list (all other values), you can select it and select sign to remove it from the classes
created for your data.
d) There are some more styling options available. You can double-click on the Symbol for
each of the classes and choose a different style from the symbol selector.

9
e) Below are examples of possible ways to symbolise Malawi_Places.
f) Explore various options and settle on a display that works best for you.

Note: For quick style changes, you may also right click on the symbol and change the style:

10
1.3. Adding Labels
It is appropriate to add some labels to identify features and provide orientation
information that will help the map reader to see the map context. Again, the software will
provide formatting options, e.g. to add labels to the Malawi_Places layer:
a) To add labels, open the layer Properties.
b) Activate the Labels dialog.
c) Select Single label from the drop-down button
d) Select Name for the value.
e) Notice there are also options to customise the labels text.
f) You can explore the options.
g) Click OK when you are done.

11
c
c

 As you can see, there are a lot of labels that are covering most contents of the map
layers.
 You know the Malawi_Places layer has three classes of places, namely, national capital,
city and town.
 Labels can be set to show only the information of certain classes. For instance, to only
show the labels of the national capital and the cities.

You can do this using Rule-Based labeling.

1.3.1. Go back to the Labels dialog in the layer properties.


1.3.2. Select Rule-Based labeling from the drop-down button.

1.3.3. Add a new rule using the + button at the bottom.

12
1.3.4. This opens the Edit Rule dialog.

1.3.5. In order to select the labels for the national capital and cities, use the following
expression:
"Class" = 'national_capital' or "Class" = 'city'

13
1.3.6. When you are done, click OK. This will take you back to the Edit Rule dialog
where you can edit the text (font, colour, placement etc).
Make sure you have Name (this is the field which has the labels) selected as
the value. Without this, the labels will not show on the map.

1.3.7. Then OK until you exit the Layer Properties dialog.

Result: There are now


fewer labels – Only the
National Capital and the
four cities.

Make sure that you are


happy with the font, size
and positioning of the
labels.

2. Task 2: Calculate area and a graduated symbol display

2.1. Calculate Geometry


To create graduated symbols you need numerical values/ranges. For instance, in the Malawi
dataset, you may want to display the waterbodies according to size:

I. Open the Malawi Water file that you have projected – e.g. Malawi water_proj
II. Open the layer’s attribute table. (Right click on the layer name – select Open
Attribute Table)

14
III. You will find that there is not a field with size (area) indicated in the attribute table.
IV. So you will create the field by calculating the size of the waterbody polygons.

V. Select the Editing mode and then the field calculator , e.g.

VI. View the result.

Note: If you forget to select the editing mode – the software will
prompt you to acknowledge the editing.

VII. Create another new field this way (one with whole numbers (integers), e.g.

15
VIII. In the example above, the field AreaSqm_I represents a rounded whole number
relevant to the AreaSqm field.
IX. You will also see that the layer is still in editing mode (There is a little pencil icon next
to the layer name in the Layers panel). Right click on the layer name and click the
Toggle Editing option to save your edits and stop the editing process.

2.2. Graduated symbols


2.2.1. The area attributes that you created in 2.1, can now be displayed in a classified way
using graduated symbols or colours.

2.2.2. From the Layer properties window, select Control Feature Symbology and then
Graduated.

16
2.2.3. Then choose the relevant attribute field (Value) and a suitable classification method
(mode) and/or number of classes, e.g.

2.2.4. Click on “Classify”.

Note that you can change the number of classes and classification method to suite your
needs. For your map submission, you need to illustrate the waterbody sizes in 3 classes.

2.2.5. It is often necessary to adjust the labels for the classes to improve legibility and
interpretation value, e.g.
Double clicking on the labels allows for editing. You can change the labels (under legend)
to appropriate labels.

17
It may also be necessary to adjust the individual range colours to make the classes more
distinct – see extract below:

3. Task 3: Create a map layout

Goal: To create a map depicting the following in ONE map layout

 The country of Malawi.


 The waterbodies in Malawi in three classes.
 The rivers in Malawi.
 The following places – symbolized according to the category
1. The capital city,
2. Cities
3. Towns.
 Label the National Capital and Cities and only.

Hint: You already created these layers in Task 1 and 2 above.

3.1. Style each layer in your map, using the skills acquired in the practical exercise.
Make sure the colours are appropriate (e.g. not too similar or too dominant) and
adjust the label font and position where appropriate.
3.2. Open a New Print Layout (this is called Print composer in earlier versions of the
software).

Project  New Print layout

Or

Icon in the main window (see below)

18
3.3. The map composer first asks you to name the print layout. Name it as you see fit.

3.4. It then opens into a composition panel, with tools along the top and right side of the
panel for creating your map.
Your Map Layout Window may look different in terms of the position of
the icons; however, all the icons are still there and look the same. (See
an example below).

19
2
11
1
3
4

5
6 7

Opening the print layout provides you with a blank canvas that represents the paper surface
when using the print option. Initially you find buttons on the left beside the canvas to
add print layout items: the current QGIS map canvas, text labels, images, legends,
scale bars, basic shapes, arrows, attribute tables and HTML frames. In this toolbar you
also find buttons to navigate, zoom in on an area and pan the view on the layout a well as
buttons to select any layout item and to move the contents of the map item.

NOTE* You can change the orientation (and other page properties) of the paper by right-
clicking on the white space and select Page properties. This will open the Item Properties

20
21
To complete the task, follow the steps below. The steps (1-11) can be completed in any
order, although it is recommended you complete them in the following sequence so you can
first familiarise yourself with the tools. (The numbers 1-7 and 11 in the text relate to the
numbers in the Figure above)
1. First things first:
On the right beside the canvas (1) you find two set of panels. The upper one holds
the panels Items and Undo History and the lower holds the panels Layout, Item
properties and Atlas generation.
i. The Items panel provides a list of all the print layout items added to the
canvas and ways to globally interact with them
ii. The Undo History panel displays a history of all changes applied to the
layout. With a mouse click, it is possible to undo and redo layout steps back
and forth to a certain status.
iii. The Layout panel allows you to set general parameters to apply to the layout
when exporting or working within;
iv. The Item Properties panel displays the properties for the selected item. Click
the select Select/Move item icon to select an item (e.g., legend, scale bar or
label) on the canvas. Then click the Item Properties panel and customize the
settings for the selected item.
v. The Atlas panel allows you to enable the generation of an atlas for the
current layout and gives access to its parameters.

2. Add a new map


The map item is the main frame that displays the map you’ve designed in the map
canvas.

i. Select the Add new map toolbar button (2), move the cursor to the
panel, and left click, hold and drag to the specific area you want the map to
display.
Simply put, select the Add new map to layout icon (2), and draw a square /
rectangle in the panel to display the map.
ii. The map will appear inside the drawn square / rectangle.
iii. You can adjust the size of the added map item by adjusting the scale in Item
properties. See figure below.

22
The scale gives you the relationship between the object on the map and its
actual size in the real world.
The scale in this case 3699991 in this case, it will be different for you. This is
a map scale of 1: 3699991, which means 1 cm on the map represents
3699991 cm on the actual ground (real world).

Change the scale to 10 000 (1:10 000). Notice what happens.


Change the scale to 60 000 000 (1: 60000000). Notice what happens.

You know that large scale maps show a smaller area with a great amount of
detail (i.e. large scale  Small area  Great detail and Small Scale  Large
area  Less detail).
Therefore, a map scale of 1:10 000 is a larger scale compared to
1:60000000, hence when you change the scale to 1:10 000, the map appears
zoomed in (Small area in more detail) while the 1:60000000 scale is zoomed
out (larger area in less detail).
Play around with the scale and settle on a scale that works best for your map layout.

3. Add a title

i. Select the Add a label Icon toolbar button (3), draw a rectangle where
you want to place the title on the main panel.
ii. A label will appear (within the drawn rectangle)
iii. You can change the label appearance properties (Text, Font, Position, Size,
Rotation etc.) in the Item Properties section on the right your screen (See
Figure Below)

23
iv. Change the font to size 20 Bold
Choose a Center Horizontal alignment and a Middle Vertical alignment
Add a frame around the title.
v. The map title should be descriptive of the content of the map.

4. Add a Legend
The Legend item is a box or a table that explains the meanings of the symbols used
on the map, therefore, it is bound to a map item.

i. Add the legend by selecting the Add legend toolbar button (4) and
follow the same process as with adding the other items (draw on the panel).
ii. By default, the legend item displays all available layers and can be refined
using its Item Properties panel.
iii. If a layer does not appear on the map, it should NOT appear in the legend.
iv. You can give the Legend a title, e.g. Legend. You can also leave it blank as it
is not necessary for a legend to have a title.

24
v. Legend entries should correctly describe the content (i.e. name layers
appropriately)
You can edit the Legend items (e.g. remove unwanted layers, change names:
 Uncheck the Auto Update checkbox in the Legends Item Properties.
 After Unchecking the box, the controls at the bottom of the Legends items
panel are activated

 To remove unwanted layers, you can use this button

 You can also add layers using this button


 To change the name, double click on the layer you want to change. A Legend
Item Properties window will appear for you to change the name.
Legend names should be descriptive and singular.

vi. You can also edit the Legend text size and font in the Items Properties.

25
vii. The legend should be appropriately positioned and in proportion with the rest
of the map elements on the canvas.
5. Add a Scale Bar
Scale bars provide a visual indication of the size of features, and distance between
features, on the map item. A scale bar item requires a map item, therefore make sure
the map item for which you are adding the scale bar is selected.

i. Add the Scale Bar using the Add Scale bar toolbar button (5) and
follow the same process as with adding the other items (draw on the panel).
ii. By default, a new scale bar item shows the scale of the most recently added
map item. You can customize it thanks to the Item Properties panel.
iii. The scale bar should be appropriately positioned and in proportion with the
rest of the map elements on the canvas.
You can adjust the Scalebar properties from Item Properties
e.g. Make the Scalebar units Kilometers.
 Change the number of Segments in the scale bar to 3 or 4.
 Change the Fixed Width to 1000 units

6. Add a North Arrow

26
A north arrow maintains a connection to a map frame and indicates the orientation of the
map inside the frame. When the map rotates, the north arrow element rotates with it.

i. Add the north arrow using the Add a New North Arrow to the Layout
toolbar button (6) and follow the same process as with adding the other
items (draw on the panel).
ii. By default, a north arrow will be added. You can change the north arrow
image using the Item properties (to the right of the screen). Under Search
directories, select and place one of the images of an arrow.

7. Some additional helpful points / hints on styling your layers:

i. Use the “Add text” tool to also add additional information / metadata (e.g. about
the map creator (you), the date of creation, and the coordinate system used)

ii. You control the extent that displays through the item properties panel. If you click
on the map, then look at its Item Properties and select “Set Map Extent to
Match Main Canvas Extent” or Set Map Scale to Match Main Canvas Scale”
(see Figure below). This will fit the map to the area you specified previously. (This

27
is useful if you mistakenly change your map scale and would like to go back to
the one it was before)

iii. You can also now adjust the symbology and labels (annotation) that you created
in Task 1 if it is no longer suitable for the map layout that you created.

8. Add a Grid
A grid is a network of evenly spaced horizontal and vertical lines used to identify
locations on a map.
i. To add a Grid, select the map you inserted earlier (i.e.Map 1).
ii. Under Item Properties, scroll down to Grids

iii. Use the + sign to add a grid, then Modify grid.


iv. Map Grid Properties
 Change the CRS to WGS 84 (EPSG:4326)
 set the X, Y interval to 1 unit
 the Line style to 0.1 width (double click on Line style)
 change the Frame style to Line border.

28
v. Scroll further down and check the Draw Coordinates box and select the
format you want for the grid coordinates.

vi. Scroll further down and disable the Right and Bottom Coordinates.
vii. You should get a grid similar to the map and grid illustrated in the Figure
below.
Note: There are many other settings available that you may use to improve the look
of you map. You are welcome to make improvements where appropriate.

29
Please note*** you can format the grid in whatever way you feel is best for you.

9. Add a map inset


Now, we will add map inset that shows a zoomed-out view of the world, showing
where Africa is in relation to the rest of the world.

i. NB!!! Before we make any changes to the layers in the main QGIS window,
check the Lock layers for map item and Lock layer styles for map item
boxes.

This will ensure that if we turn off some layers or change their styles, this view
will not change.
See figure below.

30
 Make sure to uncheck Legend Auto update so no changes are made to the
legend when you add the map insert.

 Switch to the main QGIS window. (DO NOT CLOSE the print layout!)
 Install the QuickMapServices Plugin so you can add a basemap to your
project.
Plugins  Manage and Install Plugins  Search for QuickMapServices
 Select QuickMapServices  Click Install

31
 Close the Plugins window once the plugin is installed.
 To add a basemap, go to Web  QuickMapServices  OSM  OSM
standard
A basemap will appear in the map window.
 Set the basemap CRS to EPSG 3395: WGS 84 / World Mercator.
Right Click  Set CRS  Choose EPSG 3395: WGS 84 / World Mercator.

 From here on you have two options:


 Create an inset map using Overview
 Create an inset map in a manual manner.

 Option 1: Create an inset map using Overviews – See pre-practical video


 Uncheck all other layers except for the OSM Standard basemap
 Zoom out to see more of Africa

 In the Print Layout, Add a new map


 Draw a rectangle where you want to place the map inset.
 You will now notice that we have 2 map objects in the Print Composer,
(Map 1 and Map 2). Map 2 will be the inset map.
 To make sure the contents of the inset map (Map2) matches the map
in the map window, you can “Set Map Extent to Match Main Canvas
Extent” or Set Map Scale to Match Main Canvas Scale”

32
 With the inset map still selected, add an overview from the map item
properties.
i. Click on the + button.
ii. An overview appears in the list.
iii. Select Map 1 from the dropdown list.

 You should get an inset map with Malawi highlighted.

 Alternatively, you can add an inset map manually.

33
 Option 2: Create an inset map in a manual manner.
 Now Copy the Malawi_Boundary layer and paste it in the layer panel.
i. Right Click on the Malawi_Boundary layer Copy Layer
ii. Right click in an empty space in the layers panel  Paste
later/group
iii. Rename the layer Malawi (Right Click on the layer you copied
 Rename Layer Malawi)

 The Malawi layer should be on top of the basemap.


 On the inset map, you want to show where in the Africa the Malawi is
located.
Change the Malawi layer colour to a colour that highlights it on top of the
map (e.g. red) and remove the labels
 Right Click on the Malawi layer  properties  Symbology  Select
Single symbol  change the colour to red.
 Switch to the labels tab  Select No labels.
 Uncheck all other layers except for the copied Malawi layer and the
OSM basemap.

You should have something similar to the example below.

 We are now ready to add the map inset. Switch the to Print Layout
window.

 Add a new map

34
 Draw a rectangle where you want to place the map inset.
 You will now notice that we have 2 map objects in the Print Composer,
(Map 1 and Map 2). Map 2 will be the inset map.
NB!! When making changes, make sure you have the correct map
selected.

 Select the Map object that we just added from the Items panel. Select
the Item properties tab. Scroll down to the Frame panel and check
the box next to it. Use Item Properties to style the map inset, e.g.
add a frame, etc.

 Add a heading for the inset map using the Add a label Icon
toolbar button. (e.g. Africa Map)

NB!! Should you want to go back and edit your Main Map (Map 1), make sure to
lock the Inset map (Map 2) as you did with Map 1 so anything you do does not
affect your inset map and then unlock the main map.

35
NB! Check your layout against the marking criteria (the marking rubric is also
available in the submission tab on clickUP)
Use the rubric to evaluate your document before submission. If necessary, go back to
your map layout and improve some of your map components.

4. Task 4: Export the map to an image (JPEG Format)

 You can use the Export as Image toolbar


OR
 Layout → Export as Image→ Name & select JPEG format

 Save your map in the Malawi data folder


Note: You should have a JPEG image showing Malawi, its places (with the cities and
national capital labelled), water and rivers.

5. Task 5: Add graphic to an A4 Word/Pdf document:


1. Open a new MS Word document.
2. Set the Margins smaller (To make use of most of the page).
3. Add you name, student number and the title “Practical 5 Map Submission” to the
top of the page (Format it how you like).

36
4. Paste map that you created on the page and choose the best presentation to
make it as useful and legible as possible. (Be careful not to stretch the map in a
particular direction).
5. Save the document in your folder as a Pdf file.

6. Task 6: Map submission


Submit the A4 page with your basic map layout in pdf format under Assessment and tasks
→ Practical Classwork submissions → P4 and P5 Malawi map submission.

Special acknowledgement:
A fundamental part of this practical exercise was created by student assistant Maleho Sadiki.

END

37

You might also like