2

I have a points layer in QGIS.

Each points represent a building. In the attribute table, each point has a field representing the number of HHs in the building (1 HH, 2 HHs, etc...)

I want to use the point cluster render in the layer properties to display the sum of the HHs so that when I zoom in or zoom out I can know the total number of HHs (that represent of course several points/buildings on the map).

I found a similar question here but it is not what I am looking for exactly.

4
  • So, are you asking how to base the text marker in the cluster symbol on an attribute, or how to base a heat map on an attribute, or how to add a textlabel containing said summed up attribute?
    – Erik
    Jul 12, 2021 at 12:23
  • True, basically, a text marker in the cluster symbol on an attribute. So instead of obtaining a cluster symbol labeled 2 (since it has 2 points), I will obtain a symbol label 8 for example ( 2 points and each point has 4 HHs)
    – wollyka
    Jul 12, 2021 at 12:32
  • 1
    You somehow would need to grab the ID of your cluster, in order to use sum(HH,group_by:=Cluster ID) succesfully - but I have no ID, if/how you can grab that ID.
    – Erik
    Jul 12, 2021 at 13:09
  • The problem is that I have no ID for now. The idea is that we need to group several points that have 300 HHs in total (we have to draw a border around those points in another layer). And for each group of points/segment, we will give it an unique ID. That's why I needed the sum of HHs to be displayed on the layer as text/label in order to get an idea on how should we group those points
    – wollyka
    Jul 12, 2021 at 13:39

1 Answer 1

2

You can imitate the clustering using buffers. Buffer your points (be sure to check the dissolve checkbox), create single-part geometries. Then get the sum of theHH values of all points inside the buffer.

On the buffer-layer, use this expression with field calculator (array_sum requires QGIS 3.18 or higher):

array_sum (overlay_contains( 'points', "HH"))

Points (blue, with HH value) and buffers, labeled with the the sum of the HH-value of all points inside it: enter image description here

9
  • I created the buffers and dissolve them imgur.com/8U90xVR But what do you mean by 'create single-part geometries.' Also, on the buffer layer, when to input the array_sum formula? in the label properties?
    – wollyka
    Jul 12, 2021 at 20:32
  • 1
    dissolved buffers are just one single multi-part geometry. Use Menu Vector / Geometry Tools / Multipart to singleparts. The array_sum () expression can be either used to create a new attribute using field calculator or directly as label source.
    – Babel
    Jul 12, 2021 at 20:34
  • 1
    yes, that's correct. "HH" is the name of the attribute in the layer 'points'. The expression has to be applied on the buffer layer (dissolved, singlepart)
    – Babel
    Jul 12, 2021 at 20:48
  • 1
    Sorry, from this image I cant see what you're doing. Can you share your project with data? Did you apply the expression on the layer with singlepart geometries? Can you select only one of the buffers? You have very long names for your layers, this could create a problem
    – Babel
    Jul 12, 2021 at 20:56
  • 1
    Sorry: as long as HH is empty: how should the sum be something else than 0? Where it is not 0, I get a sum > 0, see: i.stack.imgur.com/ZSVQL.jpg
    – Babel
    Jul 12, 2021 at 21:09

Your Answer

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

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