Changing layer symbology

From TOI-Pedia


Introduction

The symbology of a layer defines how it will look on the map canvas. Choosing an appropriate symbology is very important for creating effective maps. This tutorial will explain the basics of changing the symbology of both vector and raster layers.

Changing vector symbology

Basic styling

This part of the tutorial will show you how to change the basic styling of a vector layer.

We will use some OpenStreetMap data from Amsterdam as an example*. As you can see, we have added three layers to the project, each with a different type of vector geometry: water (polygon), highways (line) and public transport stops (point). We will change the symbology of each of these layers so that it corresponds better with the type of features being shown, making the map easier to read.

*(see this page for a tutorial on how to use the QuickOSM plugin to download data from OpenStreetMap).

Example map with default random symbology























Step 1: Navigate to Layer Properties
Step 2: Select the symbology tab (shown here for a point layer)
Change point marker

In order to change the basic styling of a vector layer, follow these steps:

Step 1: Right click on the layer in the layers list and select "Properties" so that the "Layer properties" window will pop up. Alternatively, you can double click on the layer and the same window will appear.

Step 2: Choose the "Symbology" tab on the left side of this window. This is where you can make all changes to the layer's symbology. The basic changes that you can make are outlined below (most depend on the layer's geometry):

  • Change colour
Click the coloured bar beside the "color" label. A colour dialog window will pop up, allowing you to select another colour.
  • Change opacity
Change how transparent the layer appears by dragging the slider beside the "opacity" label or by filling in a value in the box beside this.
  • Change point size
For layers with point geometry, fill in a value beside the "size" label.
  • Change point marker
For layers with point geometry, click on the "simple marker" layer in the symbols layer tree. Then, scroll down and you will see a variety of marker shapes to select.
  • Change line width
For layers with line geometry, fill in a value beside the "width" label.
  • Change line type
For layers with line geometry, click on the "simple line" layer in the symbols layer tree. Then, select the line type you would like from the drop-down menu beside "stroke style"
  • Change stroke colour, width and style
For layers with point or polygon geometry, change the appearance of the shape boundary by clicking on either the "simple marker" layer (point) or "simple fill" layer (polygon) in the symbols layer tree. Set the stroke colour, width and style using the dialog boxes beside each of these labels.
  • Add symbol layers
Click the green plus ("add symbol layer") button in the top right of the window. A new "simple fill / line / marker" layer will be added to the symbols layer tree. You can use this new layer to add more detail to the existing styling. For instance, for a polygon layer, you could add a hatched pattern on top of the solid fill by click on the new "simple fill" layer and changing the fill style to something other than "solid". You can also change the colour of the pattern by clicking the coloured bar beside the "fill color" label.

As well as changing the layer symbology yourself, you can select one of the pre-defined styles from the list provided at the bottom half of the symbology window. For point layers in particular, this provides some useful options. For instance, custom markers for airports, campsites and hospitals.

Step 3: Once you have made all the changes you would like to the layer's symbology then you can press "OK" and you will see that the appearance of the layers has changed on the map canvas.

Final example map with custom symbology





















For the example map, we made the following changes:

  • Water (polygon) - changed colour to light blue
  • Highways (line) - changed line colour to black and width to 0.4
  • Public transport stops (point) - changed marker colour to red, size to 3.0 and marker type to square

Categorised styling

Categorised vector styling window
Changing the color ramp

Another way to change the styling of a vector layer in a slightly more advanced way is through categorised styling. We will use the highway data from OpenStreetMap in Amsterdam as an example.

Step 0: Open the symbology tab of the layer properties (in the same way as steps 1 and 2 above).

Step 1: Select "categorized" from the drop-down menu at the top, instead of "single symbol".

Step 2: Click on the drop-down menu beside the label "value" in order to choose an attribute value to base the categorisation on. In this example, we have selected our dataset's attribute value "highway".

Step 3: Click "classify" and you will see a list of different classes appear.

Step 4: The style of each class can be changed by double-clicking on the symbol beside the name in the list. You can also change the colour ramp by clicking on the drop-down menu beside the label "color ramp". There are some pre-defined options, but you can also define your own.

Step 5: You can remove certain classes by selecting their name in the list and then clicking the minus sign at the bottom of the list.

Step 6: Click "OK" and you will see that the colours of the features of the map change based on their category. You can click on the small arrow beside the layer in the layers list to expand the list and see all category names with their symbology.


Map of highways in Amsterdam categorised by highway type

Changing raster symbology

Navigating to properties of raster layer

This part of the tutorial will show you how to change the styling of a raster layer.

For the examples in this tutorial we will use one of the grid tiles of the digital terrain model (DTM) of the Netherlands. This is a dataset thats shows the elevation of the ground surface. If you want to follow along, you can find the data here (select a grid tile and download the 5 meter raster dtm).

To open the raster layer symbology preferences, right-click on the layer, select "Properties" and navigate to the "Symbology" tab on the window that pops up.

Singleband gray

Singleband gray rendering

Raster files that are not photographs have their render type set to singleband gray by default. This means that they will appear in black and white when you open them.

It is generally better to change the styling from singleband gray to singleband pseudocolor in order for the raster's data to become properly visible and useful (see next section). However, if the grayscale gradient suits your application, it is useful to understand the following settings:

  • Colour gradient - by default this is set as black to white, meaning that high values are white and low values are black. This can also be inverted to white to black.
  • Contrast enhancement - by default this is set to "Stretch to MinMax", this means that the pixel values are stretched to the minimum and maximum values.
  • Min / max value settings - this defines how the minimum and maximum of the data are calculated, there are 4 main options:
  1. User defined - enter your own values
  2. Cumulative count cut - this cuts out the top and bottom 2% of values (you can also choose your own percentage), which is useful when you have a few extremely high or low values that you want to ignore
  3. Min / max - the real or estimated min/max of the data (you can select the accuracy of the calculation as either "estimated (faster)" or "actual (slower)" beside the "accuracy" label)
  4. Mean ± standard deviation - this calculates the min/max based on the mean and standard deviation


Singleband pseudocolor

Singleband pseudocolor rendering

This render type allows you to make a raster layer more colourful instead of using the default greyscale.

Change the styling to singleband pseudocolor by using the drop-down menu beside the "render type" label.

Useful options:

  • Colour ramp: there are a number of pre-defined colour ramp options or you can also define your own.
  • Interpolation type:
  • Linear (default)
  • Discrete (each class represents values below or equal to the number in the value column)
  • Exact (each class represents values equal to the number in the value column)
  • Mode:
  • Continuous (default)
  • Equal interval (ensures that the values are equally distributed)
  • Quantile (values are distributed based on data quantiles)
  • Classes: the number of value classes (only applicable to the modes "equal interval" and "quantile").

Note: you may need to click "classify" if you have made changes to the interpolation type, mode or classes so that the changes are applied.




The before and after shot below shows how changing the styling from singleband gray to singleband pseudocolor alters the appearance of a raster tile from the digital terrain model (DTM) of the Netherlands. In this example, the mode was set to "equal interval" and 10 classes were selected in the symbology layer preferences.


QGIS raster before.png
QGIS raster after.png


Changing transparency

Changing transparency of raster layers

The transparency of a raster layer can be changed by navigating to the layer properties and selecting the tab "Transparency" on the left. You can either use the slider or fill in your own value in the field beside this.

Raster toolbar

Another way to change the styling of a raster is by using the raster toolbar. Enable the tool via View » Toolbars » Raster toolbar. You should see the following icons added to the QGIS interface:

Raster toolbar icons







You can use this toolbar to change the rendering of a layer using the following options (listed from left to right):

  • Option 1 - Local cumulative cut stretch using current extent, default limits and estimated values
  • Option 2 - Cumulative cut stretch using full dataset extent, default limits and estimated values
  • Option 3 - Local histogram stretch
  • Option 4 - Stretch histogram to full dataset
  • Option 5 / 6 - Increase / decrease brightness
  • Option 7 / 8 - Increase / decrease contrast
  • Option 9 - Georeferencer (not related to raster styling)


Options 1 and 3 are useful if you want improve the contrast of a local area that you have zoomed into. The tool does this by stretching the minimum / maximum values based on the values in the area shown on the map canvas extent. When you zoom out again you will notice that using these options changes the rendering of the full raster. You can change back to the original rendering by using option 4.

Example - contrast improvement

To the left you can see the original rendering of a zoomed in portion of a raster DTM tile. To the right you can see how applying option 3 to this area improves the local contrast.

Original rendering - zoomed in area
Local histogram stretch - zoomed in area


















Below you can see how applying option 3 to the zoomed in area affects the rendering of the full raster layer. Note how the contrast of all areas other than the zoomed in area gets worse when option 3 is applied since the min/max values have been set to improve the contrast of only the zoomed in area.


QGIS rastertool before full.png
QGIS rastertool after full.png

Useful links

Footnotes

Personal tools
Actions
Navigation
Tools