7.10.1. Layer styling and labelling
Some basic settings in the Layer Properties for styling were already discussed in this tutorial (see sections 7.3.4. and 7.3.5.). Based on this experience, we will look at some more techniques to visualise different geometry types and attribute information together:
- Add the vector layer commune_boundary_FR.shp to the QGIS project (see section 7.3.3.).
- Double-click this layer in the Map Legend to open the Layer properties.
- Select Style.
- Select Graduated instead of Single Symbol.
- Choose an attribute (e.g. “Shape_Area”).
- Choose a number of Classes (e.g. 7) and the Mode Natural Breaks (Jenks).
- Choose colour ramp (e.g. “BuPu”).
- Click Classify.
- Click Apply (the Layer Properties can stay open).
As an intermediate result, all polygons (representing different municipalities) are filled with a colour from the chosen spectrum corresponding to the chosen attribute (e.g. “Shape_Area”). This is already a good start, but perhaps the map should also provide the names of the communes?
- Switch to the Label tab (Fig. 118).
- Activate the checkbox to display labels.
- Choose an attribute field that should be displayed (e.g. “GEMNAME”).
- Feel free to adjust font size and colour or the placement options below.
- Click OK.
- Activate and select the layer bees_colony_locations_buffer.shp created in section 7.6.1.
- Place it at least one level higher than commune_boundary_FR.shp.
- Open again the Layer Properties.
- Select the Style tab.
- Click the button Change.
- Choose Outline: Simple line as Symbol layer type.
- Select a dark colour (e.g. black), a Pen width of about 0.25 and Dot Line as Pen style. Confirm with OK.
- Set the transparency to about 30%.
- Close the Layer Properties of bees_colony_locations_buffer.shp.
- Move the layer bees_colony_locations.shp on top of the Map Legend and open its Layer Properties.
- Not only do colours and attributes matter for the visualisation of spatial data, but also size. To demonstrate this, select the size 5, click Advanced > Size scale field and choose an attribute field of your choice (e.g. “sum”).
- Adjust the Size to reach a good result on the Map View. The honey bee colonies close to the city of Fribourg have now the smallest symbols, the ones closer to arable land and forests are bigger.
- Switch to tab Diagrams (Fig. 119).
- Activate the checkbox Display diagrams and choose Pie chart as Diagram type.
- Set the Size to about 8 mm, the Placement AroundPoint with a Distance of 6.
- Now add some content for the pie charts: Use the Button to add the fields 211mean, 312mean, 313mean and other (see section 7.9.). The colours can be adjusted by double-clicking on the coloured bar.
- Make the changes permanent by clicking Apply and close the Layer Properties with OK.
- Save the QGIS project (and all the layer styling you have done so far)
by the menu File > Save.
The result (Fig. 120) is already a good start for a first visualization of geodata and it will serve as an example for the next paragraphs describing map creation functions.
In some cases it makes sense to save the layer symbology not only within a project, but also for different layers. This can be done layer by layer at the bottom of the Layer Properties dialog (see Fig. 118) using the button Save Style. This will safeguard all styling information in a *.qml-file. You can import these styles later also into other projects and apply the styles to more layers (Layer Properties > Load Style) – so this is probably the most important time-saver for larger mapping projects within QGIS.
Fig. 118. Setting labels based on attributes.
Fig. 119. Creating diagrams based on layer attributes.
Fig. 120. Map View after changing layer style properties and labelling options.