Versions Compared

Key

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

QGIS Point Cluster Styling

Introduction

This module shows how densely populated point data can be styled using clustering, with OpenStreetMap data being used as an example.

Load data

  1. Open the PointCluster project

  2. Install the QuickOSM plugin if it’s not already installed - this will allow us to download OpenStreetMap data

  3. Navigate the map to the Bristol area

  4. Go to Vector > QuickOSM > QuickOSM to open the QuickOSM dialog, from which you can run queries to download OSM data

  5. Complete the dialog as per the screenshot below, and click Run query

  6. New layers will be added to the map, showing data for pubs in the area you have selected

  7. You will get two layers with polygon and point data

  8. Create a centroid layer from the polygon layer

  9. Merge it with the point layer so that you have a single layer containing all the pubs in Bristol on OSM (you can find the Centroids and Merge vector layers tools using the search box)

Set initial styling

  1. Add a Single Symbol style to the data, using an appropriate SVG  marker under Symbol Layer type for the Simple Marker

  2. You should now have a representation of pubs in the city, though some of the points will probably overlap - we are going to address this using point clustering

Add point clustering

  1. Go back to Symbology, and choose Point Cluster as the type, then Apply

  2. You will see that where pubs are within a certain distance of each other, the points are replaced by a point cluster marker, showing the number of pubs represented by the marker

  3. This is useful, but it would be better to use our custom symbol rather than the default red symbol

  4. Click on the Cluster symbol button, and change the Simple marker to an SVG marker, using the same settings as for your original marker

  5. You may need to change the size of the marker or the font to ensure that the numbers are visible

  6. Your map should now look something like this

Add data dependency to symbol size

The map might be more useful if we could make the size of the symbols dependent on the number of pubs in the cluster.

  1. In the Cluster symbol dialog, click on the Font marker, and notice that the symbol to the right of the font characters is highlighted in yellow - this means that a data dependency has been set

  2. Click on the symbol - it shows that the @cluster_size function is being used to generate a number to show in the symbol
     

  3. We can use this function to drive the symbol size - click on the SVG marker

  4. Click on the Data defined override button  to the right of Width, and select Edit from the menu (note that you may have to resize the window to see this button)

  5. In the Expression dialog, type @cluster_size  

  6. When you apply the style, the marker size will vary depending on the size of the cluster

  7. Adjust the size of the marker and the font, using a multiplier on the @cluster_size function if necessary, until you have a style you are happy with

Using geometry generators

There are QGIS styles which support geometry transformations, such as buffering and centroids, on the fly. We can use these, for example, to show as points the pubs which are represented as polygons.

  1. Turn on the polygon pubs layer

  2. In Symbology, select Single symbol and click on Simple fill

  3. Change the Symbol layer type to Geometry generator

  4. Click on the expression icon on the right, and search for centroid - you can then use this to create an expression centroid($geometry) to show the polygons as centroids

  5. Note that you will also need to set the correct output Geometry type (in this case Point/MultiPoint), so your dialog should now look like this

  6. Add appropriate styling and apply

  7. Experiment with other geometry generators - for example buffers to show the areas within a certain distance of a pub (note that to do this you should first export the data as British National Grid so you can set the buffer size in meters)

Note that we can't use the point clustering with the geometry generator - you would need to create a new layer with centroids of the polygons for this.

...