QGIS – Topological Colouring

Marketing
Marketing
  • Updated

By David Crowther

QGIS___Topological_Colouring_-_1.PNG

Question:

How can you randomly colour polygons in a layer within QGIS?

Answer:

The Topological Colouring Tool within QGIS enables you to create a Colour_ID field in your layer so that you can then randomly colour the features.  

In QGIS below I have a Polygon Layer showing the Wards for the London Borough of Islington.

QGIS___Topological_Colouring_-_2.PNG

From the Processing menu choose > Toolbox > and open the Cartography section.

QGIS___Topological_Colouring_-_3.PNG

Choose the Topological Colouring menu option.

QGIS___Topological_Colouring_-_4.PNG

The Topological Colouring will open.

QGIS___Topological_Colouring_-_5.PNG

We will use the following settings:

  • In the Input Layer choose the LBI Wards
  • In the Minimum number of colours choose 4
  • The Balance Colour options are:
    • by Feature Count – where the count of features assigned the same colour is balanced.
    • by Assigned Area – where colours are assigned to balance the total area covered by each colour – we will use this one!
    • by Distance between colours – where colours are assigned to maximise the distance between the same colours.

QGIS___Topological_Colouring_-_6.PNG

If you now Run the Topological Colouring tool the output will be a copy of the original Layer, with an added Colour_ID field which will contain a value that we can then use to colour the polygons with.

QGIS___Topological_Colouring_-_7.PNG

Using the Symbology > Categorised option > on the Colour_ID field, we can classify the data on all the unique Colour_ID values.

QGIS___Topological_Colouring_-_8.PNG

Once we Apply the thematic, the polygons in the input layer will be coloured so that no touching polygon has the same colour!

QGIS___Topological_Colouring_-_9.PNG

If we were to change the settings in the Topological Colouring tool e.g. using the distance between colours method and choosing 6 different colours – the result will look different.

QGIS___Topological_Colouring_-_10.PNG

This is such an easy tool to apply random colours to your layers in QGIS!

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.