1

Is there a way to obtain the same spatial rendering as what QGIS 3 allows with Point Cluster symbology (spatially close points clustered in a unique symbol) but using an attribute based categorization? Potentially without multiplying layers? I have been trying this expression

aggregate( @layer_name,'sum',"Nombre",filter:= "Nature" = attribute( @parent , 'Nature') AND intersects(buffer($geometry,10),geometry(@parent))))

But it doesn't work as I would like it to... the expression keeps duplicated points. If I have 2 points within a 10 m range, one with a value 2, the second with a value 3, the expression will show two points with a value 5. Is this expression a dead-end? If not, how to remove "duplicates"? If yes, back to the initial question...

1
  • If you are looking for a point cluster centroid, see this post
    – JGH
    Aug 22, 2023 at 12:45

1 Answer 1

0

Scope To group points according to distance criteria (here, a buffer distance of 5m from a point) and attribute value criteria. Each point has a category attribute and a numerical attribute corresponding to its eigenvalue. This eigenvalue will then be added together for points located within the 5m buffer zone and made visible by the diameter of the circle used as a representation. [For the record, the visual rendering of different values by circles of increasing area is given by the formula n*Value^0.5 (the square root [^0.5] of the value [Value] multiplied by the diameter of the circle for a value of 1 [n, here 2 mm]).

Symbology Select 'categorized' and categorize according to 'Category' values For each category value, a 'geometry generator' is used as a symbol, corresponding to the following expression :

centroid(aggregate(
layer:=@layer_name,
aggregate:='collect',
expression:=@geometry,
filter:="Category" =attribute(@parent,'Category') 
AND intersects(buffer(@geometry,5), buffer(geometry(@parent),5))))

The following are operations on the symbol below the geometry generator, which will include a font symbol and a simple symbol. Font symbol (expression to be inserted in the "Character(s)" expression window)

aggregate(
layer:=@layer_name,
aggregate:='sum',
expression:="Value",
filter:="Category" =attribute(@parent,'Category') 
AND intersects(buffer(@geometry,5), buffer(geometry(@parent),5)))

Simple symbol size (expression to be inserted in the "Size" expression window)

CASE
When "Category"='A'
Then 2*aggregate(
layer:=@layer_name,
aggregate:='sum',
expression:="Value",
filter:="Category" =attribute(@parent,'Category')
AND intersects(buffer(@geometry,5), buffer(geometry(@parent),5)))^0.5
END

And there you have it. If we didn't need to give a value from an attribute, and each point had a value of 1, we'd replace 'sum' with 'count' in the last two expressions.

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.