[Qgis-user] Sum of field value within same cluster

Charles Dixon-Paver charles at kartoza.com
Tue Jun 22 07:14:30 PDT 2021


I agree that I think there was a misunderstanding in the requirement,
however I am unsure how you resolve this with expressions.

In my view, an aggregate expression is what you need, but I am unsure how
you would be able to retrieve the cluster geometry. The current expression
is buffering each feature geometry so it's finding nearby neighbouring
points, not identifying clusters.

You could feasibly collect the geometries within each cluster and retrieve
a centroid that is buffered using expressions, but identifying which points
form a part of each cluster would be difficult.

You could probably perform various K-means/ DBSCAN clustering operations to
get this at the various scales that you need though, then use that
attribute value with an expression similar to centroid(collect( $geometry,
 "CLUSTER_ID" )). Once that is done though, you won't need to use the
spatial intersection in the aggregate expression anymore anyway.

Again, you'll be challenged to find the right buffer distance to make this
effective, and be able to exclude individual points. This makes the effort
and utility of the automatic clustering symbology less than ideal for your
use case as you could generate these styles yourself. It may be easier to
pay a developer to expose the cluster geometry to the QGIS expressions API.

Hopefully that's helpful and not totally confusing.

Regards

On Tue, 22 Jun 2021 at 15:03, Dario C <dario955i at gmail.com> wrote:

> Hi Alexandre,
> thank you for your reply, but I'm not sure I got it. I don't want to see
> the @cluster_size (number of symbols within the cluster), but the sum of a
> specific field.
> I don't know what "@cluster_value" is. I see only @cluster_size
> and @cluster_colour as options.
>
> Thanks
>
> Il giorno mar 22 giu 2021 alle ore 12:12 Alexandre Neto <
> senhor.neto at gmail.com> ha scritto:
>
>> Hi Dario,
>>
>> You don't need such complicated expression. There's a cluster variable
>> that returns the value for you. It's @cluster_value.
>>
>> This is well documented here:
>>
>>
>> https://docs.qgis.org/3.16/en/docs/user_manual/working_with_vector/vector_properties.html#point-cluster-renderer
>>
>> Hope it helped.
>>
>> Alexandre Neto
>> QGIS Support
>> www.qcooperative.net
>>
>>
>>
>> A terça, 22/06/2021, 09:55, Dario C <dario955i at gmail.com> escreveu:
>>
>>> Hi,
>>> I think I'm on the right way using this expression:
>>>
>>> aggregate('LayerID','sum',"FIELD",filter:=intersects(buffer($geometry,60),geometry(@parent)))
>>>
>>> [image: image.png]
>>> In point cluster I set 5 mm as distance (size of symbol is 4mm), so I
>>> thought that the buffer of my expression needed to be 5. Actually 5 does
>>> not work, so I changed to 5 multiply by the scale of the drawing
>>> (1/12.000), so I set 60.
>>> The point is that it works not so precise. In the screenshot you can see
>>> that, when you have two cluster close each other, the total sum is correct,
>>> but some parts are shifted to another cluster.
>>>
>>> Thanks for your help
>>>
>>>
>>>
>>> Il giorno dom 20 giu 2021 alle ore 15:15 Dario <dario955i at gmail.com> ha
>>> scritto:
>>>
>>>> Hi,
>>>> I’m working on a big scale, so I need to see my points using point
>>>> cluster.
>>>> I’d like to see as label the sum of a specific field of the point of
>>>> the same cluster.
>>>>
>>>> I started using aggregate expression and buffer intersection as filter,
>>>> but nothing good...
>>>>
>>>> Thank you in advance.
>>>>
>>>> Cheers mm
>>>>
>>>> _
>>>
>>> _______________________________________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>
>> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210622/69930994/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 21210 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210622/69930994/attachment.png>


More information about the Qgis-user mailing list