I've been having a play with the new point cluster renderer in QGIS 3.0.2 and it's great - a lot easier (and faster) than having to do the clustering yourself.

To show what I mean, here's an example of road accidents in Edinburgh using STATS19 data and a 30m radius.

enter image description here

I can't work out how to set up the z-order so that the largest clusters are drawn in front of smaller clusters.

I'm aware of the @cluster_size variable - it's what I'm using to scale and colour the symbols. For this I'm using the size and colour assistants. I removed the font markers to remove the text from each cluster.

Size of markers is defined as follows:-

coalesce(scale_exp(@cluster_size, 0, 50, 1, 200, 0.57), 0)

Colour of markers is defined as follows:-

coalesce(ramp_color('custom ramp',scale_linear( @cluster_size, 0, 50, 0, 1), '#000000')

What I've tried so far:-

  • Symbol Levels - No luck; unable to select a variable name.
  • Layer rendering > Control Feature Rendering Order and choose @cluster_size as sort. Doesn't appear to have an effect.
  • Graduated style using @cluster_size as the expression doesn't work.

Does anyone know if this is possible, or is this a limitation with this particular renderer?

I know there's a lot of other ways to do this (buffer/spatial join, plugins), but the new renderer should be a lot faster. Or have I overlooked something obvious? :)

  • It probably works by taking the order in the attribute table into account. Perhaps you arrange them in ascending order so that the largest ones are rendered as the newest? If there is no function 'Sort features by attribute', you can try the MMQGIS plugin (if its available for qgis 3)
    – Revo
    Commented Sep 28, 2018 at 12:34
  • thanks @Revo. It seems to be possible to size & sort it on an attribute (including with Cluster Point renderer), but that only works at one scale. I tried to use cluster_size because cluster sizes change dynamically as I zoom in/out using the cluster point renderer. I'll take a look at MMQGIS (it is available for QGIS 3)
    – Steven Kay
    Commented Sep 28, 2018 at 18:13

1 Answer 1


It seems as though the point cluster implementation does not allow for this natively.

Consider the point cluster renderer - it essentially analyzes and clusters point data at render time, creating a new pseudo layer. This layer is not accessible to the user. One cannot query a clustered point. One cannot field calculate a @cluster_size attribute.

The point cluster renderer does inherit render order from the source using Control feature rendering order (QgsFeatureRequest::OrderByClause) leaving open the possibility of some clever workaround using attributes and expressions, however certain ordering schemes are not guaranteed to be consistent.

As an example, consider a point layer with rendering ordered ascending by a "Latitude" attribute. The more northerly points are rendered atop more southerly points. The point cluster renderer does not have a "Latitude" attribute for its new features, though it will inherit some semblance of that order from the source. There can be instances when a more southerly cluster renders atop a more northerly cluster, because of the order of the original points.

  • Thanks. That's a very clear explanation, which also answer my question whether it is possible to compute an attribute from the clustered points, say i.e. a sum of the population associated to each original point. Clearly not....yet? It would be a very useful feature though. Any idea on how this can be achieved with some smart workaround (which doesn't require coding though, as I am not (yet, again?) good at it), even in a static way? I am struggling to find a tool to cluster points similarly to the way it is done by cluster-renderer
    – dorakiara
    Commented May 15, 2019 at 12:48
  • Generally speaking, you could approach this by replicating what the cluster renderer does in conjunction with the 'Control feature rendering order' function using attributes. A rough first pass could be to buffer a point layer, count points in the buffered polygons as an attribute in points layer. Control render order by this attribute ascending. A bit cumbersome and will not necessarily work at different scales. Commented Jun 5, 2019 at 14:39
  • I would also encourage you to make a feature request, which would expose the @cluster_size method to the 'Control feature rendering order' function. Commented Jun 5, 2019 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.