19

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 Sep 28 '18 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 Sep 28 '18 at 18:13
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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