Advanced Cartography & Map Design I

BEN HUR S. PINTOR

Advanced Cartography & Map Design I

BNHR

Credits & License

Advanced Cartography & Map Design I

by Ben Hur S. Pintor

version 2020.05

This work and its contents by Ben Hur S. Pintor is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

You are free to:

Share — copy and redistribute the material in any medium or format

Adapt — remix, transform, and build upon the material

Under the following terms:

Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

NonCommercial — You may not use the material for commercial purposes.

ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

Other works (software, source code, etc.) referenced in this work are under their own respective licenses.

About this workbook

About the Author

Geospatial Generalist. Open Source & Open Data Advocate. Maptivist.

Ben Hur S. Pintor has worn many hats over the years. He received his Bachelor’s degree in Geodetic Engineering from the University of the Philippines and, at the time of this writing, is working towards his Master’s degree in Geomatics Engineering with a specialization in GeoInformatics. His first experience with QGIS was with version 1.5 Tethys in 2010 but he started using it consistently in 2012 with version 1.8 Lisboa. After graduating from university, he worked on several projects where he used and advocated for open source GIS. During this time, he also started providing training and workshops on open source GIS. In 2019, he founded BNHR (https://bnhr.xyz) in order to help people solve data and spatial problems and make better decisions using open technologies like QGIS. He is a QGIS Certified Instructor and currently the only QGIS Sustaining Member in the Philippines.

Learn more about him at https://bnhr.xyz.

Acknowledgements

Standing on the shoulders of giants.

This workbook is an ever evolving piece of work that reflects my learnings and realizations over the years. The information provided here consists of my own experiences and those that I’ve gathered from the experiences of others from where I have taken inspiration.

The names of everyone I’ve learned from over the years may be too many to mention but I would like to acknowledge the QGIS Project and its volunteers for the Official QGIS Documentation and User Guide and the local and global FOSS4G and QGIS communities among the many inspirations and resources that I had in creating this workbook.

Contents

Advanced Cartography & Map Design I        0

Credits & License        2

About this workbook        3

About the Author        3

Acknowledgements        3

Contents        4

Introduction        5

What you should already know        5

Other learning resources        5

Colors        6

Creating your own Color Scheme        6

Exercise 1: Creating your own color scheme        6

Color Palettes in QGIS        12

Preview Modes        14

How would my maps look like when photocopied, faxed, or when viewed by a colorblind individual        14

Exercise 2: Previewing your maps in different modes        14

Layer Styling        16

Blending Modes        16

Exercise 3: Using Blend Modes to Style Rasters        17

Bivariate choropleth maps in QGIS        20

Exercise 4: Bivariate choropleth maps in QGIS        20

Emphasizing density with Feature-level blending        24

Exercise 5: Showing road density using feature-level blending        24

Data-defined overrides        26

Draw effects        26

Exercise 6: Mapping Icebergs in QGIS        27

Geometry generators        34

Exercise 7: Generating centroids and buffers using geometry generators        34

Labelling        36

Labels in QGIS        36

Exercise 8: Basic Labelling with Leader Lines        36

The Style Manager        40

QGIS Style Components        41

Importing Styles into the Style Manager        41

Exercise 9: Importing Styles into QGIS        41


Introduction

This workbook is designed to teach participants how to use advanced cartography and map design techniques in QGIS focusing on advanced symbology and labelling.

By the end of the workbook, you should know: how to use data-defined overrides, geometry generators, advanced labelling techniques, draw effects, blending modes, color palettes, among others.

What you should already know

As an intermediate level workbook, you are expected to already know basic GIS concepts such as spatial data models and formats and QGIS functions such as loading and styling layers, running processing algorithms, saving QGIS projects, etc.

Other learning resources

Official QGIS Documentation (QGIS 3.10)

Official QGIS Documentation (testing)

BNHR blog

BNHR Facebook & Twitter

Free and Open Source GIS Ramblings by Anita Graser

Klas Karlsson’s Youtube channel

QGIS User Group Philippines Facebook Page

Geographic Information Science Philippines Facebook Page

Colors

Creating your own Color Scheme

QGIS allows you to create your own color scheme or color palette that easily gets integrated into QGIS’ built-in color selection dialogs. This is useful when you have a set of colors that you usually work with (i.e. branding) or if there are standard colors for the maps that you are creating (i.e. HLURB Land Use and Zoning Standards).

Exercise 1: Creating your own color scheme

In this exercise we will create a new color scheme in QGIS that reflects the HLURB CLUP Guidebook Annex on Land Use Categories and Color Coding (HLURB_CLUP_Vol_3_Annex_1.pdf).

Figure 1. HLURB Land Use Categories and Color Coding sample

  1. Open the Color Options via Settings -> Options -> Colors in the Menu bar.

Figure 2. Colors Options in QGIS

  1. QGIS has some built-in color schemes. You may check them out by selecting them from the dropdown button. Initially, the Standard colors color scheme is shown.
  2. To create a new Color scheme, click the  button next to the Color scheme dropdown button and select New Palette. Name your new palette as HLURB-CLUP.

Figure 3. Create New Palette

Figure 4. Name the New Palette

  1. A blank color palette should appear with the name HLURB-CLUP selected in the dropdown button.

Figure 5. Blank HLURB-CLUP Color Scheme/Palette

  1. Now we need to fill up our color palette. We can use the buttons on the right side of the dialog to do this. These buttons have the following functions:
  1.          Add new color
  2.          Remove color
  3.          Copy color
  4.          Paste color
  5.         Import color from file
  6.         Export colors
  1. Let’s add the colors from the HLURB Guidebook. Click  to open the add color dialog. To add the Forest Zone category, add a color with RGB = 0, 100, 0.
  2. Rename the Label to Forest Zone.

Figure 6. Add the Forest Zone color (RGB 0, 100, 0)

Figure 7. The Forest Zone color added to our Scheme/Palette

  1. Do the same for all categories. In our case, let’s add a color for each Base zone (Bold Categories in the Guide) since the sub-zones have the same color as the base zone.

Figure 8. The HLURB-CLUP Color Scheme/Palette

  1. Now, we can add this color palette to the QGIS color selection dialogs by clicking  and checking Show in Color buttons.
  2. Afterwards, this palette should always appear in the color selection dialogs in QGIS.

Figure 9. Show the palette in the QGIS Color Buttons

Figure 10. The HLURB-CLUP color palette appearing in the QGIS color button/dialog

Color Palettes in QGIS

QGIS also has a lot of built-in color palettes to choose from aside from the ones shown when selecting color palettes in the color selection dialog (e.g. raster symbology).

For example, QGIS has built-in cpt-city color palettes and even a palette creator using Color Brewer.

This option can be found by clicking Create New Color Ramp… when a color ramp dialog is present.

Figure 11. Palette options in QGIS

Figure 13. cpt-city color palettes in QGIS

Figure 12. Create New Color Ramp


Preview Modes

How would my maps look like when photocopied, faxed, or when viewed by a colorblind individual

One of the advantages of Color Brewer palettes in QGIS is that most of them are color blind safe. When selecting a color palette or color scheme for your maps, it is useful to make it as inclusive as possible in order to correctly relay information to the most people as possible.

There are several applications that allow you to select and create inclusive color palettes. These include sites like the aforementioned ColorBrewer (https://colorbrewer2.org/) and Viz Palette (https://projects.susielu.com/viz-palette).

In QGIS, you can use Preview Modes to see how your map would look like photocopied, faxed, or if viewed by someone with color blindness. This option can be found via View -> Preview Modes in the Menu bar.

Exercise 2: Previewing your maps in different modes
  1. Load the stompcovidph_provinces vector layer in QGIS.
  2. Apply a Graduated symbology.
  3. For the Color ramp, create a new color ramp by selecting Color Brewer and the YlOrRd palette with 5 colors.
  4. Select Natural Breaks (Jenks) for the Mode. Your layer should appear like below.

  1. Go to Views -> Preview Mode and select Simulate Color Blindness (Deutoranope). Your layer should appear like the one below.

  1. Try to use the other preview modes with other color palettes.

Layer Styling

Blending Modes

SImilar to graphics manipulation applications such as GIMP and Photoshop, QGIS has what’s called Blending Modes that allow for more sophisticated rendering between GIS layers. There are 13 blending modes which (aside from the Normal mode) can be divided into four groups. These modes are:

  • Normal
  • Lighten
  • Lighten
  • Screen
  • Dodge
  • Addition
  • Darken
  • Darken
  • Multiply
  • Burn
  • Contrast
  • Overlay
  • Soft light
  • Hard light
  • Inversion/Cancellation
  • Difference
  • Subtract

Blending mode properties are available for both vectors and rasters and can usually be found in the Layer Rendering part at the bottom of the Styling Panel (F7) or Layer Properties -> Symbology dialog.

QGIS Blend Modes by Steven Kay

Exercise 3: Using Blend Modes to Style Rasters

In this exercise, we’ll utilize the power of Blend Modes to style a raster similar to this post:

https://bnhr.xyz/2019/01/22/hillshade-in-qgis.html

  1. Load the SRTM_Albay raster and duplicate the layer.
  2. Name the original layer as colored and the duplicate as hillshade pertaining to the style that we will use for the layers.

Rasters loaded in QGIS

  1. Style the hillshade layer with a multidirectional hillshade.
  1. Select Hillshade as Render Type
  2. Set Z Factor to 2.0
  3. Check the Multidirectional checkbox
  4. Select Cubic and Average for Resampling with Oversampling at 2.0
  5. The layer should look like the one below.

Hillshade layer styled

  1. Style the colored layer with a singleband pseudocolor symbology.
  1. Select Singleband pseudocolor as Render Type
  2. For the Color ramp, BrBG works great
  3. Edit the Classification intervals

Colored DEM layer styled

  1. Select Blending mode as Multiply
  2. Select Cubic and Average for Resampling with Oversampling at 2.0

Combined colored and hillshade layer

  1. Another trick I’ve found is adding/overlaying satellite imagery. For this, load a satellite image (e.g. Google Satellite basemap) covering the area.

Satellite imagery loaded in QGIS

  1. Style the satellite image layer.
  1. Select Blending mode as Overlay
  2. Update the Brightness, Contrast, and Saturation
  3. Select Cubic and Average for Resampling with Oversampling at 2.0

Combined colored,  hillshade, and satellite image layer

Bivariate choropleth maps in QGIS

Bivariate choropleth maps are both stunningly beautiful and informative. With the right color combination, a bivariate choropleth map hits that sweet spot of being both visually stunning and highly informative.

Exercise 4: Bivariate choropleth maps in QGIS

In this exercise, we will create a bivariate choropleth map in QGIS similar to the one done in this post:

https://bnhr.xyz/2019/09/15/bivariate-choropleths-in-qgis.html

  1. Load the stompcovidph_provinces vector layer and make a duplicate. Since we’ll be creating a bivariate choropleth map, we need 2 vector layers to show. In this case, we’ll show the case fatality rate (cfr) and the recovery rate of the provinces. As such, name the layers cfr and recovery rate.

The cfr and recovery rate layers

  1. Next, we make a choropleth map of the cfr layer.
  1. Symbology - Graduated
  2. Column - cfr
  3. Classes
  1. < 5%
  1. Color: #e8e8e8
  2. Values: 0 - 5
  1. 5% - 25%
  1. Color: #dfb0d6
  2. Values: 5 - 25
  1. > 25%
  1. Color: #be64ac
  2. Values: 25 - 100
  1. Use a white (#ffffff) stroke color for all styles.

Choropleth of  cfr layer

  1. Next, we make a choropleth map of the recovery rate layer.
  1. Symbology - Graduated
  2. Column - recovery_rate
  3. Classes
  1. < 5 %
  1. Color: #e8e8e8
  2. Values: 0 - 5
  1. 5% - 25%
  1. Color: #ace4e4
  2. Values: 5- 25
  1. > 25%
  1. Color: #5ac8c8
  2. Values: 25 - 100
  1. Use a white (#ffffff) stroke color for all styles.

Choropleth of the recovery rate layer

  1. Change the Blending mode of the top layer (cfr) to Multiply.

Bivariate choropleth of cfr & recovery rate

Emphasizing density with Feature-level blending

Using blending modes on the feature-level is useful when we want to emphasize density (or de-emphasize sparseness). This is particularly useful for feature-rich datasets with multiple overlapping geometries such as roads.

Exercise 5: Showing road density using feature-level blending

In this exercise, we will highlight areas with dense road densities using a simple feature blending technique.

  1. Load the stompcovidph_provinces vector layer and style it as all black (#000000) or any dark color. This will make for a great basemap for our glowing road density map.
  2. Load the highway_primary vector layer. This layer consists of highways/roads tagged as primary from OSM. Style Style this to use blue (#2d4cd9) as its color. As you might notice, the road layer appears dull.

 

The road layer looks dull and areas with dense road networks  aren’t emphasized

  1. We will use a simple trick to make this map glow and emphasize the areas with dense road networks. Under the Layer Rendering options of the highway_primary layer, select Addition for the Blending mode under Feature.

  1. Try to play around with line width, color, transparency., and other styling combinations to see what works best for you.

Data-defined overrides

Data-defined overrides are powerful tools in QGIS. Through this mechanism, a user can use dynamic values for styling parameters such as color, size, rotation, etc. A data-defined override is available for a parameter when the  button appears to its right. Clicking on the Data-defined override button reveals the different options available for the user. The override can be based on:

  • A field/attribute value
  • A QGIS expression

For an override to work, it must be in the same type as the value it is overriding. For example, a size parameter must be overridden by a number, a color parameter must be overridden by a string pertaining to a color. When a data-defined override is active, the button turns yellow .

Draw effects

Since QGIS 2.10, draw effects have been available in QGIS that allows the user to modify and add different effects to the rendering of vectors. These effects can be activated and modified by enabling  and clicking the draw effects button (star).

The different effects available to the user are:

  • Inner Glow
  • Inner Shadow
  • Source
  • Outer Glow
  • Outer Shadow
  • Blur
  • Colorise
  • Transform

The opacity and blend mode can also be modified for each effect. The rendering order of the effects can also be changed via the arrow buttons.

Draw effects are useful for adding glows and shadows to features and layers (i.e. firefly maps).

Exercise 6: Mapping Icebergs in QGIS

In this exercise, we will use data-defined overrides and draw effects to map icebergs in QGIS similar to this post:

https://bnhr.xyz/2019/02/08/mapping-icebergs-in-qgis.html

  1. Load the Icebergs (2008-2017), World Graticules 10D, and World Graticules 20D vector layers.
  2. For a world map, enter world in the coordinate bar of the status bar.

  1. First, change the CRS of the project to the South Pole Orthographic projection (ESRI: 102037).

  1. Change the Project background color to dark gray (#474747) via Project -> Properties -> General.
  2. Apply a Gradient fill symbology to the world map using #474747 (75% opacity) and #474747 (100% opacity) as the endpoints of a color ramp.

  1. Let’s add a glowing effect to the coasts using Draw effects.
  1. Duplicate the World layer.
  2. Select Simple fill as Symbol layer type
  3. Set Fill color to transparent
  4. Set Stroke color to dark orange (#ff7f00)
  5. Check Draw effects under Layer Rendering
  6. Add an Inner Glow and Outer Glow effect with the following properties:
  1. Color: dark orange (#ff7f00)
  2. Spread: 2 mm
  3. Blur radius: 2 mm

  1. Duplicate the World Graticules 10D layer and filter so using "display" = '10 S'. We’ll use this layer to create the blackish effect around our map. Put this as the first layer in the layer panel.
  1. Select Simple line as Symbol layer type
  2. Set Stroke color to dark gray (#494747)
  3. Check Draw effects under Layer Rendering
  4. Add an Inner Glow and Outer Glow effect with the following properties:
  1. Color: dark gray (#494747)
  2. Spread: 10 mm
  3. Blur radius: 10 mm

  1. Style the World Graticule 20D layer.
  1. Select Simple line as Symbol layer type
  2. Set Stroke color to green (#02db00)
  3. Select Solid line as Stroke style
  4. Check Draw effects under Layer Rendering
  5. Add an Inner Glow effect:
  1. Color: green (#02db00) with 50% Opacity.
  2. Spread: 2 mm
  3. Blur radius: 4 mm

  1. Style the World Graticule 10D layer.
  1. Select Simple line as Symbol layer type
  2. Set Stroke color to green (#02db00)
  3. Select Dashed line as Stroke style
  4. Check Draw effects under Layer Rendering
  5. Add an Inner Glow and Outer Glow effect:
  1. Color: green (#02db00) with 50% Opacity.
  2. Spread: 2 mm
  3. Blur radius: 4 mm

  1. Style the Icebergs (2008-2017) layer.
  1. Select Simple marker as Symbol layer type
  2. Use Data defined override for the Size
  1. Field: size (meters at scale)
  1. Set Fill color to white
  2. Set Stroke color to cyan (#16f3d6)
  3. Check Draw effects under Layer Rendering
  4. Add an Inner Glow effect:
  1. Color: cyan (#16f3d6) with 70% opacity
  2. Spread: 2 mm
  3. Blur radius: 2 mm

  1. Instead of the glow effect, you can also try to use the feature-level Addition blending mode on the Icebergs layers.

Geometry generators

Geometry generators allow you to create new geometries using QGIS expressions and existing geometries. This means that we can create polygon, lines, and point geometries without the need for creating new layers. For example, you can generate a buffer geometry from a point layer or a centroid geometry from a polygon layer. Geometry generators also allow us to create complex geometries and styles.

When working with geometry generators, it is important to remember that the correct geometry type has to be set in order for the geometry generator to work. For example, if the final geometry is a point (e.g. centroid) select Point/Multipoint as the geometry type. If it is a polygon (e.g. buffer), select Polygon.

Exercise 7: Generating centroids and buffers using geometry generators

In this exercise, we will generate centroids and buffers using geometry generators.

  1. Load the stompcovidph_provinces layer and create a duplicate.
  2. In the Styling Panel, select Geometry generator in the Symbol layer type and Point/Multipoint in the Geometry type.
  3. Enter centroid($geometry) -- this QGIS expression tells QGIS to generate/compute the centroids for the feature geometries.
  4. The resulting layer represents the centroids of the polygon features and can then be styled as such.
  5. What if I want to generate a buffer from the centroids based on the number of active cases, how can I use geometry generators to do that?


Labelling

Labels in QGIS

QGIS has a very mature and customizable label mechanism. Data-driven overrides, QGIS expressions, and even geometry generators can be used when labelling.

Another feature of labels in QGIS is that they can be moved manually anywhere on the map canvas.

Exercise 8: Basic Labelling with Leader Lines
  1. Load the stompcovidph_provinces layer.
  2. Apply  a graduated symbology using the active field/attribute.
  3. Create a centroid layer by using the Centroid processing algorithm.
  4. Filter the Centroid layer to show only the features where active > 500.

  1. On the Centroid layer, apply a label. The label styling options can be found by right clicking the layer -> Layer Properties -> Labels or via this tab  in the Layer Styling Panel.
  2. Add a SIngle Label with the following expression as value: concat(province, ‘: ‘, active). What we’re doing is labelling the layer with the name of the province and the number of active cases.
  3. Add a simple buffer to the text for better readability.

  1. Move the legends to the blank space to the right of the Philippines.
  1. Click in the Labels Toolbar.
  2. Click on one of the labels.
  3. Select a primary key for joining the auxiliary information (i.e. position data of the label) with the main layer. In this case, the fid would do.

  1. Move the legends to the right where they are more readable.
  2. Note the position of the dot/circle. This is the position of the label. In this case, it is the lower left corner which is the default.

  1. Let’s add the leader lines.
  1. On the Centroids layer, add a new Symbol layer by clicking .
  2. Set the Symbol layer type as Geometry generator and the Geometry type as Linestring/Multilinestring. This symbology will be our leader lines to the labels.
  3. Enter:

make_line(

make_point(

"auxiliary_storage_labeling_positionx",

"auxiliary_storage_labeling_positiony"

), $geometry)

  1. Notice that the leader lines attach themselves to the lower left corner (position of the dot) of the label. How can we change this?
  2. Click  in the Labels Toolbar and click one of the labels. Which option can help us change where the leader lines connect to?

The Style Manager

The QGIS Style Manager allows the user to manage different style components of QGIS. It can be accessed via Settings -> Style Manager in the Menu bar.

QGIS Style Components

In the Style Manager, the user can find the different styles for points (markers), lines, polygons (fills), color ramps, text formats, label settings, and legend patches. Using the Style Manager allows the user to have reusable and consistent style components. A style can be created once, stored in the style manager, and used multiple times. The Style Manager also allows for sharing of styles between different users so one user can create a style and share it with others to use.

Importing Styles into the Style Manager

DIfferent style components can be imported into the style manager either as files or as URLs. Once imported, these styles then become available for use inside QGIS.

Exercise 9: Importing Styles into QGIS

For this exercise, we’ll be importing the wonderful QGIS styles made by Topi Tjukanov (@tjukanov) available from https://github.com/tjukanovt/qgis_styles.

  1. Open the Style Manager via Settings -> Style Manager in the Menu bar.
  2. Click  and select Import Item/s.
  3. If you downloaded the qgis_styles repo by tjukanov, you can use File and select the necessary file.
  4. You can also add the styles via the URL of the style’s XML file. For example, for the Qlimt style, this URL is https://raw.githubusercontent.com/tjukanovt/qgis_styles/master/collections/style_xml/qlimt.xml

  1. Select the qlimt item and click Import.
  2. Try to do this for the other styles made by @tjukanov.
  3. Once imported, these styles become available in QGIS and can be updated and modified just like any other style.

BNHR

This work and its contents by Ben Hur S. Pintor is licensed under a

Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.