QGIS-A06: QGIS Point Cluster Styling v3.28
6. QGIS Point Cluster Styling
6.1. Introduction
This module shows how densely populated point data can be styled using clustering, with OpenStreetMap data being used as an example.
6.2. Load data
Open the PointCluster project
Install the QuickOSMÂ plugin if itâs not already installed - this will allow us to download OpenStreetMap data
Navigate the map to the Bristol area
Go to Vector > QuickOSM > QuickOSM to open the QuickOSM dialog, from which you can run queries to download OSM data
Complete the dialog as per the screenshot below, and click Run query
New layers will be added to the map, showing data for pubs in the area you have selected
You will get two layers with polygon and point data
Create a centroid layer from the polygon layer
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)
6.3. Set initial styling
Add a Single Symbol style to the data, using an appropriate SVGÂ marker under Symbol Layer type for the Simple Marker
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
6.4. Add point clustering
Go back to Symbology, and choose Point Cluster as the type, then Apply
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
This is useful, but it would be better to use our custom symbol rather than the default red symbol
Click on the Cluster symbol button, and change the Simple marker to an SVG marker, using the same settings as for your original marker
You may need to change the size of the marker or the font to ensure that the numbers are visible
Your map should now look something like this
6.5. 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.
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
Click on the symbol - it shows that the @cluster_size function is being used to generate a number to show in the symbol
ÂWe can use this function to drive the symbol size - click on the SVG marker
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)
In the Expression dialog, type @cluster_size Â
When you apply the style, the marker size will vary depending on the size of the cluster
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
6.6. 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.
Turn on the polygon pubs layer
In Symbology, select Single symbol and click on Simple fill
Change the Symbol layer type to Geometry generator
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
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
Add appropriate styling and apply
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.