Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Numberedheadings
number-formatdecimal
skip-headingsh3, h4HNaN
start-numbering-with3
h1[h1.decimal].start-numbering-with3
h2[h1.decimal].[h2.upper-latin]
h3
h4
h5
enabledtrue
h6
start-numbering-atH1

Styling in QGIS

Style needs to be added to data to give it a useful visualisation on the map. Styles can be very simple (for example 'colour everything blue'), or more complex, with multiple rules and elements. This module covers some basic styling approaches and techniques, with pointers to more advanced techniques.

The Style Dialog

QGIS applies a random style to every layer when it is loaded (otherwise layers would not be visible). Set your own style using the Symbology tab in the Layer Properties dialog.

The table below lists the main style types QGIS supports - this course will cover those highlighted. Some styles are only available for certain geometry types.

Symbology type

Geometry

Description

Example

Comment

No symbols

All

The layer will not appear on the map.

Display the data using labels only


Single symbol

All

The same symbology will be used for all features

Location of villages

Symbol can be sized proportionately to an attribute value - for example population

Categorized

All

A different symbology will be used for each unique value of an attribute

Crime types

Depending on values, each feature could have a unique style, or features could share the same style

Graduated

All

For numeric data only, values can be 'banded', with each band having a different style, usually using a graduated colour ramp

Voting patterns

Number, size and statistical composition of bands can be set by user

Rule-based

All

One or more rules can be used to determine styling

Ordnance Survey MasterMap

Used to apply more complex logic to styling, for example where the content of more than one attribute is used to determine style

Point displacement

Point

Move points slightly if they are in the same location, or within a set tolerance of each other, so that they are all visible

Crime locations

Where representation of numbers is more important than geographical accuracy

Point cluster

Point

Coalesces points which are in the same location or within a set tolerance of each other into a single symbol, with a number showing the count of the points included

Crime locations

Where representation of numbers and geographical accuracy to a certain zoom level is required, with numbers of points coalesced changing with zoom level

Heat map

Point

Continuous surface of varying colour and intensity based on point density

Bird nesting locations

Best used to visualise point locations over an homogenous area

Inverted PolygonsPolygons

Polygon

Applies any styling inside the polygon to areas outside the polygon instead

Feathered border

Can be used to apply focus to polygons

2.5 D

PolygonsPolygon

Applies 3D-like shading based on fixed height values or attribute value

Buildings

QGIS also generates full 3D views

Apply Styling

  1. Open essentials_03_styling.qgz and save it with a new name

  2. Create a Single Symbol style for the canal_crt layer

    1. Double-click on the layer, and go to the Symbology tab

    2. Click on Simple Line to amend the properties of the existing style

    3. Choose one of the styles in the lower part of the dialog and make some amendments to

come
    1. some of the style components (click on the Favorites dropdown above the symbols and change the setting to All Symbols to see more options)

    2. Click Apply to see the effect of your changes without closing the dialog

    3. Click OK when done

  1. Create a Single symbol style for the wind_turbines_point layer, using an SVG or Font marker

    1. Go to Symbology for the layer

    2. Click on Simple Marker, and change the Symbol Layer Type below it to SVG Marker

    3. Select an

appropriate (or inappropriate)
    1. SVG image from the dialog, and change the size and colour to suit

    2. Do the same thing using Font Marker instead of

an
    1. SVG Marker (choose a font such as Wingdings or Webdings)

  1. Create a Categorized style for the osmm data using the theme attribute

    1. In Symbology, choose Categorized from the dropdown at the top, and set Value to theme

    2. Click Classify at the bottom of the dialog to set the colours

    3. Double-click on the symbol for each value to change its style

  2. Apply a Single Symbol style to aonb_wales, with some transparency or hatching so that the base layer can be seen behind it

  3. Create appropriate symbols and name labels for the railway_naptan layer

  4. Create a Graduated style for the

neighbourhoods
  1. neighbourhood_

crime layer, using the total_crime attribute
  1. crimes layer

    1. Select Graduated from the dropdown

    2. Select total_all for the

value
    1. Value

    2. Click

classify
    1. Classify and review the results

    2. Change the setting of Mode, reclassify and see how this changes the visualisation

Labels and Annotations

Any data in the attribute table can be added to the layer as a label, and labels can contain expressions - for example to include data from multiple columns. You can also add, format and position individual labels using Annotations.

Add Labels

  1. In the properties for railway_naptan, go to the Labels tab and select Single Labels from the dropdown

  2. Set the Value to StationName and click Apply at the bottom of the dialog to see the effect

  3. Change the Font settings under Text in the lower part of the dialog to make the labels more prominent

  4. Add a Buffer to the labels to make them stand out against a darker background

  5. Look at the Placement and Rendering settings, make some changes and see what the effects are

Annotations are standalone labels which can be formatted in a number of ways to suit your requirements. They need to be created, formatted and positioned individually - this takes more time, but gives more control over the end result.

Add Annotations

  1. Turn on the Annotations toolbar

  2. Click on Text Annotation (the button far right)

  3. Click on the map to add the annotation

  4. Click and drag the red marker to move the geographical anchor point of the annotation, and click and drag the annotation box to position it

  5. Double-click on the annotation box to add content and formatting

  6. Add some content, and change the Frame style and Map marker

  7. Add and format more annotations if you have time

Sharing and Reusing Styles

Once you have created a style, you can re-use or share it on in a number of ways, and you can also load styles created by others. This example covers the use of a ready-made style - for this you are going to use OS MasterMap, and load a saved style from a qml file.

Reusing Styles

  1. Zoom to the extent of the osmm layer - the sample covers the city of Exeter

  2. Go to Symbology for the layer, then Style > Load style and navigate to ../QGIS Training/Data/styles/osmm_topo_area.qml

  3. Click Load Style then OK to load the Ordnance Survey QML style file and apply it to the data

  4. Have a look at the style, and how it is constructed - this one is Rule-based

  5. Open the railwayline layer from the vector folder and zoom to it

  6. Right-click on the canals_crt layer, then Style > Copy Styles > All Style Categories

  7. Right click on railwayline, then Style > Paste Styles > All Style Categories - this will copy the style you created for canals to the railway lines layer

  8. In the Symbology tab for railwayline, click Style (at the bottom), then Save Style - this dialogue will save the style as a QML file for use later, or for sharing with others

This section covers the use of a ready-made style - for this you are going to use OS MasterMap, and load a saved style from a qml file.

QGIS and SLD

QGIS can export to Styled Layer Descriptor (SLD) format, although some not all styles are not supported. SLD is an OGC standard which is supported by a number of programmesapplications, including Astun’s iShare.

Images

QGIS uses Scalable Vector Graphic (SVG) images as its native image format - other formats such as PNG and JPG can only be used if they are embedded in a SVG file. Graphics programs such as InkScape can be used to create SVG images.

...