By David Crowther
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.
From the Processing menu choose > Toolbox > and open the Cartography section.
Choose the Topological Colouring menu option.
The Topological Colouring will open.
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.
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.
Using the Symbology > Categorised option > on the Colour_ID field, we can classify the data on all the unique Colour_ID values.
Once we Apply the thematic, the polygons in the input layer will be coloured so that no touching polygon has the same colour!
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.
This is such an easy tool to apply random colours to your layers in QGIS!
Comments (0 comments)