11

I'm trying to make a cluster visualization of a vector point layer about trees with a few requirements:

  • The clusters need to change depending on zoom level (solved)
  • The clusters need to indicate how many vector objects are clustered (solved)
  • The clusters need to have labels that describe the objects that are clustered
  • This needs to be done with styling, so that the CRS can be copypasted (the data table will be updated and the clustering needs to be automatic)

I would like to show something like this in the final product (I inserted the black text by hand in MS Paint for reference):

enter image description here

The data for the trees:

enter image description here

The Point Cluster is only a visualization, so automatic labeling will create labels to individual objects, not to each cluster. Also, the @cluster-functions are only available inside the Cluster Point styling context. This is why I would like to make another layer with Cluster Points styling, which has a Font Marker as the cluster symbol. The text for the symbol would need to have conditional formatting. I would do it in SQL with something like this:

select count(*), "type" 
from @cluster
group by "type";

Which would yield something like this:

enter image description here

This would show the text in the way I need it on each different zoom level. However, I can't find a way to get a grip of the objects inside each cluster. The @cluster does not actually work.

How do I make grouped text clusters with Cluster Point styling, and how do I get a hold of the objects inside clusters?

2
  • 1
    If QGIS doesn't have this functionality, it would be a great feature to request.
    – csk
    Commented Jul 13, 2018 at 14:07
  • If you haven't already, check out [this question}(gis.stackexchange.com/questions/282417/…). In that case I found a workaround, but the fundamental issue is that the cluster renderer only has two expression variables: @cluster_size and @cluster_color. I don't know any way to label features based on whether they're in a cluster. But maybe someone else will think of a creative workaround.
    – csk
    Commented Jul 13, 2018 at 14:42

1 Answer 1

1
  1. Right-click the clustered layer
  2. Select ‘Properties…’
  3. Select the fourth icon ‘Label’ on the left
  4. At the top of the window, you can see that the default setting is ‘Single Labels’.
  5. In the ‘Value’ field, click the dropdown arrow and select the field you want to label, e.g. count, type enter image description here
  6. Right-click the clustered layer again and choose ‘Duplicate Layer’, then repeat the above steps
  7. If the labels overlap enter image description here
  8. Click the icon below in the label toolbar. This will enable you to move the labels to the desired location

enter image description here

enter image description here

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.