Chapter 6 A Map of Wolfville

6.1 Purpose

  • Demonstrate how to assign styles to vector layers using a single symbol, a categorized symbology, a graduated symbology and a rule-based symbology.
  • Suggest a set of styles to use for common layers such as roads, rivers, lakes, and contours.
  • Practice using the Print Composer to export maps from QGIS.

6.2 Tutorial

  • Add layers
  • Single symbols
    • Style simple polygons
    • Style simple lines
    • Style simple points
    • Style advanced polygons
    • Style advanced lines
    • Style advanced points
  • Categorized Symbols
  • Rule-based Symbols
  • Graduated Symbols

6.2.1 Adding the Data

To start, we’re going to add a lot of layers to the map at once. It’s quite time consuming to do this using the Add Vector Layer dialog, so I suggest using the drag-and-drop approach, dragging the “CanVec Data” folder into the Layers panel. If you do use the Add Vector Layer dialog, remember to only select the “.shp” files.

Slide01

Slide01

Select all of the vector layers, then choose OK.

Slide02

Slide02

6.2.2 Simple Polygons

The map looks nothing like a topographic map, which is, in the end, what we are trying to accomplish. The first layer we will modify is the “water_poly” layer. We will first open the Layer Properties dialog, which you can open by double-clicking on the layer, or by right-clicking the layer and selecting Properties.

Slide03

Slide03

Choose the Style tab, and then click on the water layer style. Choose OK to apply the style and close the dialog.

Slide04

Slide04

Next we will modify the vegetation layer. Open the Layer Properties dialog for this layer by double clicking, or right-clicking and selecting Properties.

Slide05

Slide05

Choose the “Green” style, and click OK to dismiss the dialog and apply the style.

Slide06

Slide06

Next, we will modify the “urban_areas” layer. Open the Layer Properies dialog for this layer.

Slide07

Slide07

There is no acceptable pre-made style for this layer, so we will have to make our own. The simplest modification possible is to change the fill colour. To do this, click on the color, or click on the little arrow next to the color and click Choose color….

Slide08

Slide08

This will open a dialog that allows you to choose a colour. Urban areas are often represented in yellow fill on maps, so choose a shade of yellow (or another colour of your choice). Click OK on both dialogs to apply the style and close the dialogs.

Slide09

Slide09

There is also a bulidings polygon layer. Open the Layer Properties dialog for this layer.

Slide17

Slide17

Then, choose a black fill and choose OK.

Slide18

Slide18

6.2.3 Simple Lines

Next, we will modify the streams layer. Open the Layer Properties dialog for the stream layer.

Slide10

Slide10

QGIS comes with a collection of Standard colors, which fit many needs. The light blue is particularly good for representing water layers, such as streams.

Slide11

Slide11

The default line width in QGIS is 0.26 mm, however this is too small for streams to be visible. Set the width to 0.5 mm. and choose OK to apply the style and close the dialog.

Slide12

Slide12

Next, we will modify the “roads” layer. Open the Layer Properties dialog for this layer.

Slide13

Slide13

Set the colour to black, and the width to 0.75 mm.

Slide14

Slide14

The next lines layer we will modify is the “contours” layer. Open the Layer Properties dialog for this layer.

Slide15

Slide15

You can choose one of the standard colours for the contours, or a better one if you have one offhand.

Slide16

Slide16

6.2.4 Simple Points

The only point layer on this particular map is the point buildings layer. To modify its style, open the Layer Properties dialog.

Slide19

Slide19

There are a few choices for point shapes, and for the buildings layer we will choose the square shape with a Size of one. Choose OK to apply the style and close the dialog.

Slide20

Slide20

6.2.5 Symbol Layers

There are some layers that can’t be represented with a simple line. A good example is the “railroads” layer, which is typically represented by a line with various cross-hatches. There is no built-in symbol for this in QGIS, so we will have to create one ourselves. Open the Layer Properties dialog to start.

Slide21

Slide21

First, set the Color to black. Then click the green “+” symbol to add a Symbol layer.

Slide22

Slide22

This will add another symbol that will be drawn on top of the black line. Under Symbol layer type, choose Marker line instead of Simple line.

Slide23

Slide23

Next, we need to customize the marker that is drawn repeadedly on top of the original black line. Choose the Simple marker symbol layer to customize this marker.

Slide24

Slide24

Choose the vertical line marker, and press OK to apply the style and close the dialog.

Slide25

Slide25

A similar symbol is the symbol for dykes or berms. To modify this style, open the Layer Properties dialog for the “dykes” layer.

Slide26

Slide26

Change the colour of the line to black, and choose the green “+” symbol to add a symbol layer.

Slide27

Slide27

Change the new Symbol layer type to a Marker line.

Slide28

Slide28

Choose the Simple marker symbol layer, and change the marker to the vertical line.

Slide29

Slide29

The symbol is now the same as the railroad symbol. To make the ticks to on only one side of the line, we need to change the size of the tick and the offset of the tick. Change the Size to 1.0 mm, and the Y Offset to 1 mm.

Slide30

Slide30

Finally, in the Marker line layer, change the interval to 2 mm.

Slide31

Slide31

6.2.6 Rule-based Styles

Next, we will revisit the “contours” layer. Contours on maps generally have labels, and generally have a thicker contour every fifth line. We will now start to use the attribute table to dictate various aspects of layer styles through Rule-based styles, Labels, Categorized styles, and (in a later tutorial) Graduated styles. Rule-based styles are the most complex of the three, however their use in formatting the contour layer is common. Open the Layer Properties dialog for the “contours” layer.

Slide32

Slide32

From the dropdown at the top left, choose Rule-based instead of Single Symbol.

Slide33

Slide33

Now, add a new rule using the green “+” symbol.

Slide34

Slide34

Next, add a label for the rule. The labe of “major” (as in major and minor contours) is fitting for our application. Click the “…” to create the rule interactively.

Slide35

Slide35

Under Fields and Values, select “elevation” and double-click it to add it to the Expression.

Slide36

Slide36

The expression we will use is ("elevation" % 50) = 0. Without going into too much detail, this will apply our rule to all features where the elevation is a multiple of 50. Since the contour interval for this map is 10, this will be every fifth contour. Choose OK to close the dialog.

Slide37

Slide37

Next, we have to set the style for our “major” contours. This should be the same colour as the original contours, but slightly thicker (a Size of 0.5 mm). Choose OK to close the dialog.

Slide38

Slide38

Choose OK on the Layer Properties dialog to close the dialog and apply the style.

Slide39

Slide39

You should now have some contours that are thicker than others.

6.2.7 Labels

Contours are generally labeled on topographic maps. To add labels, open the Layer Properties dialog on the “contours” layer.

Slide40

Slide40

Choose the Labels tab, and pick the “elevation” field under Label this layer with.

Slide41

Slide41

There are a number of additional options for labels, a few of which we will apply to labeling of contours. The first is the text size, which I generally make between 8 and 10 points. For contours, I usually make the label the same color as the contour line itself.

Slide42

Slide42

You can also apply a number formatting, which for contours is probably helpful.

Slide43

Slide43

An important component of labels on maps is the Text buffer. I always use a text buffer for labels on maps, usually with a Size of 1 mm and a color of white. If this is too stark a contrast on a map, I adjust the transparency or change the buffer colour.

Slide44

Slide44

Finally, we want to update the placement to make sure contour lines are labeled on top of the line instead of somewhere else. Choose OK to apply the labeling and close the dialog.

Slide45

Slide45

6.2.8 Categorized Styles

Currently, the “water” layer looks like it contains separate polygons for different categories of water bodies. We want to label these differently on our map, but to do so we need to know what attribute defines the difference between them so we can use it to apply a Categorized style. Select the “water_poly” layer and switch to the Identify tool.

Slide46

Slide46

Click on the centre water polygon in the Minas Basin and inspect its attributes.

Slide47

Slide47

Now click on the outer water polygon and inspects its attributes, noting that there is a difference in “permanency” between the two. This make sense, because at high tide these areas are covered in water but at low tide they are not.

Slide48

Slide48

To apply the Categorized style, open the Layer Properties dialog for the “water_poly” layer.

Slide50

Slide50

From the dropdown menu at the top of the Style tab, choose Categorized.

Slide51

Slide51

Under Column, choose “permanency”, then click Classify.

Slide52

Slide52

In the window, you should see a list of permanency values. To modify the styles for features that have this value for permanency, double click on the row.

Slide53

Slide53

For a permanency value of 1, we simply want a “water” style. Click OK to apply the style.

Slide54

Slide54

For a permanency value of 2, we want a slightly different symbol. Double click the row to open the dialog to choose the style.

Slide55

Slide55

Select the “water” style (this will be the base style), but then click the green “+” sign to add a new symbol layer.

Slide56

Slide56

Instead of a simple fill, choose a Point pattern fill. This is similar to the Marker line we used earlier, but for polygons.

Slide57

Slide57

Next, change the pattern of points from a grid to an offset grid by changing the Horizontal distance to 3 mm, the Vertical distance to 3 mm, and the Horizontal displacement to half that value (1.5 mm).

Slide58

Slide58

Finally, change the Color of the marker to black.

Slide59

Slide59

And the Size of the marker to 0.2 mm. Click OK to apply the style.

Slide60

Slide60

Finally, click OK to close the dialog and apply the style.

Slide61

Slide61

6.2.9 Polygons with Outlines

Sometimes, a polygon represents an outline more so than an area that should be filled. The “cemetaries” layer is an example of a layer of this type. Open the Layer Properties dialog for this layer.

Slide62

Slide62

Next, choose Simple fill in the symbol layers list to modify the advanced parameters of the fill.

Slide63

Slide63

Instead of filling the polygon with a Solid fill, choose No Brush.

Slide64

Slide64

You can also modify the outline style in a similar way to modifying a regular line. Choose Dash Line for the outline style.

Slide65

Slide65

Set the Border width to 0.75 mm.

Slide66

Slide66

Finally, change the border color to black and press OK to apply the style and close the dialog.

Slide67

Slide67

6.2.10 Point Symbols at Multiple Scales

If you zoom in close, you will notice that no matter how far zoomed in/out you are, buildings will always be 2 mm in diameter. This works well for some zoom levels, but not others. To modify this behaviour, open the Layer Properties dialog for the “buildings_point” layer.

Slide68

Slide68

Instead of refering to the symbol Size in millimetres, we can also specify a size in Map units. For buildings, that represent a structure on the ground, this is a good choice.

Slide69

Slide69

Set the Size to 20 (a good approximation, since buildings are about 20 m across, and our project CRS in in metres). Press OK to close the dialog.

Slide70

Slide70

Buildings should now be appropriately sized when zoomed in…

Slide71

Slide71

…and zoomed out.

Slide72

Slide72

6.2.11 Raster Layer Styles

Raster layers are slightly different to style, since they contain a single geometry (collection of cells) that may represent many different types of values. We will start by adding a Digital Elevation Model (DEM) of the Wolfville Area. You can do this using the drag-and-drop approcach or using Add Raster Layer.

Slide73

Slide73

With any luck, you should see a black-and-white raster layer appear over Wolfville. The default style for a raster layer is black as low and white as high. Just as we can change the defaults for vector layers, we can change the style of raster layers by opening the Layer Properties dialog.

Slide74

Slide74

There are several options for styling a raster layer. The default is Singleband gray, however Singleband pseudocolor is the most useful.

Slide75

Slide75

To apply a colour gradient to the raster image, you can select a colour gradient, and then click Classify.

Slide76

Slide76

If you apply the style, you should see something like this.

Slide77

Slide77

You can also increase the transparency of the raster to see below it.

Slide78

Slide78

In general, you will also want to rearrange the layers so that each is visible. A good rule of thumb is to put raster layers at the bottom, followed by polygons, followed by lines, followed by points. This isn’t always the best ordering, but will usually produce a good place to start.

Slide79

Slide79

Your map should now look like this.

Slide80

Slide80

6.3 The Assignment

What we’ve just done is the “first pass” to make things look “about right”. You will always have to do this before you tweak all the colours and styles to be just how you would like. Over many years of creating maps with Canvec Data, I’ve settled on the following as my “best guess” for creating a good map. You’ll learn how to download CanVec data of your own in the next section.

6.3.1 Water Polygons

Unless there’s something that looks funny, I usually go with the pre-defined “water” style with a thin (0.1 mm) outline. The details of this are as follows:

  • Fill: #a5bfdd (hint: you can copy the text including the hash tag and choose Paste Color from the color chooser)
  • Outline: usually none (outline style as No Brush) or very thin, the same colour as the water (0.1 mm).

6.3.2 Forest

Forest polygons should be a light green fill (#d0eadd), with no outline or a very thin outline (0.1 mm) with the same colour as the fill.

6.3.3 Stream Lines

  • Colour: The same as the fill colour for the water polygons (#a5bfdd).
  • Size: 0.5 mm

6.3.4 Contour Lines

  • Rule-based style, with the rule for major lines as ("ELEVATION" % 50) = 0.
  • Colour: #bb8c6e
  • Size: 0.26 mm (minor) and 0.4 mm (major)
  • Labels: Text colour the same as the contour line, font size 8 points with a white, 0.5 mm text buffer positioned on top of the line.

6.3.5 Building Polygons

  • Colour: black
  • Outline: None

6.3.6 Building Points

  • Shape: Square with no outline
  • Size: 25 (in map units). You will have to have a project CRS that is in meters (most other than lat/lon are).
  • Rotation according to the “orientation” or “rotation” attribute

6.3.7 Wetlands

There were no wetland (or “saturated soils”, as NRCan calls them) layers in this dataset, but they are available.

  • Fill: #d0eadd (this is a light green) with a simple fill layer above it with colour #a5bfdd and Fill style “Dense 4”.
  • Outline: None

6.3.8 Roads

Roads are tricky, because to properly render them as a Categorized style where freeways are a specific colour requires some advanced QGIS style magic. Usually you want them to be black with a width of 0.5 mm or so. If you really want to try a classfied symbology, you can classify them by the ROADCLASS field. You will have to enable Symbol levels for the built-in road symbols to function properly.

6.3.9 Railways

The railway symbol I always use is the one I’ve described here, usually changing the size of the crossways symbol and the spacing of the ticks to suit the final project.

6.3.10 Urban Areas

I almost never include this layer, but occasionally it helps. I usually use a fill colour of #fdff73 with no outline.