Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

3. 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.

3.1. 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 Polygons

Polygons

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

Polygons

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

Buildings

QGIS also generates full 3D views

  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 of the style components (click on the Favorites dropdown above the symbols and change the setting to All Symbols to see more options)

  3. 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) SVG image from the dialog, and change the size and colour to suit

    4. Do the same thing using Font Marker instead of an SVG Marker (choose a font such as Wingdings or Webdings)

  4. 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

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

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

  7. Create a Graduated style for the neighbourhoods_crime layer, using the total_crime attribute

    1. Select Graduated from the dropdown

    2. Select total_all for the value

    3. Click classify and review the results

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

3.2. Sharing and Reusing Styles

There are a number of ways to re-use a style. You can:

  • Copy/paste styles between layers: select the layer, right-click > Copy (or Paste)

  • Save a style in the QGIS native file format, .qml, for importing to another project: double-click the layer > Layer Properties > Symbology > Style > Save Style > QGIS Layer Style File

  • Save a style as an SLD (Styled Layer Descriptor), for use in other applications which support it: double-click the layer > Layer Properties > Symbology > Style > Save Style > SLD File

  • Load a style from QML or SLD: double-click the layer > Layer Properties > Symbology > Style > Load Style

QGIS and SLD

QGIS does not yet support all of the SLD standard in its export and import - there are some styles which will not be translated. You may also need to do some tweaking of the SLD file (which is in XML), depending on the application you are working with.

  • Create and import style libraries (groups of styles) for example for corporate use: Settings > Style Manager > Import / export

  • Set a style as a default, to be used when a layer is added to a project. This works well if the layers are stored in a PostGreSQL database, as the default styles are available to any user. File-based default styles are normally only be available to the local user: double-click the layer > Layer Properties > Symbology > Style > Load Style > Save as default 

3.3. 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. Images can be used in all geometry types - for point styles, for area fills, and for markers on a line. SVG images can be coloured and scaled, and combined to create composite images, so they are more versatile than some other formats.

To use an SVG image:

  • In the Symbol Selector dialog (where a specific symbol is configured), from the Symbol Layer Type dropdown list select SVG marker

  • Select the SVG marker to use from the library, or use the file manager view to browse to your own SVG image

  • Adjust the settings such as size and colour to suit your needs

3.4. Labels

Labels are also configured from the Layer Styling dialog (the Style Dock). To activate the labels dialog:

  • Click the button at the top of the Layers panel , or hit F7

  • In the Labels dropdown, select Single Labels

  • In Value, select the column to be used for labels


You can now adjust a range of settings for labels, including font, placement and formatting. 

Here are a few pointers and tips:

  • If some labels are not appearing on the map, this may be because they are conflicting with other labels and so have been removed. Use Show all labels for this layer in the Rendering tab 

     so you can see all labels

  • Use the settings in the Buffer tab

     to draw a buffer or halo round labels so they stand out against a darker background 

  • Use the Expression Builder button 

     (next to the Label with field) to build labels with expressions - for example concatenating two or more attribute values, or creating a total of numeric values

3.5. Annotations

Annotations provide a means of adding labels or images to a map which independent of the data. The formatting is flexible, so while by default they look like callouts, they can also be made to look like labels.

Create annotations by clicking the Text Annotation button in the Attributes toolbar - once this is activated, every time you click on the map canvas, an annotation will be created. Double-click an annotation to edit its properties: text, style, frame, marker etc.


  • No labels