5

From a layer of points 'POINTS_LAYER', I create the concave_hull using the following expression:

smooth(simplify(buffer(concave_hull(
            collect(
                $geometry,
                group_by:=overlay_nearest(@layer, "class"))
                ,0.0),0.75),2.0),5)

I add the screenshot with the result:

enter image description here

I am labeling the perimeter with this expression:

 format_number(round(perimeter(smooth(simplify(buffer(concave_hull(
            collect(
                $geometry,
                group_by:=overlay_nearest(@layer, "class"))
                ,0.0),0.75),2.0),5)),1)) || ' m'

I would like to label with a dynamic expression the calculated perimeter in percentage relative to the perimeter of the aggregated polygonal layer 'POLY_LAYER'. For example, if the layer 'POLY_LAYER' has a perimeter of 346.000 m, and the concave_hull created has a perimeter of 104.948 m, I would like to label the calculated percentage that represents the perimeter of the concave_hull with regards to the polygonal layer (30.06%) as you can see in this simulation:

enter image description here

2
  • 1
    When you say "the aggregated polygonal layer 'POLY_LAYER'", what do you mean? Is there only ever one feature in that layer, or can there be multiple features? And do you need to link those features with particular features in the point layer? Commented Oct 15, 2023 at 23:04
  • 1
    According to the needs of my project, the polygonal layer has only one feature. So, the solution you propose fits perfectly to the objective and is a good solution in my case Commented Oct 16, 2023 at 4:37

1 Answer 1

4

If there is always just one feature in the 'POLY_LAYER' then you can use an expression like:

with_variable('points_perimeter', 
    perimeter(smooth(simplify(buffer(concave_hull(
            collect(
                $geometry,
                group_by:=overlay_nearest(@layer, "class"))
                ,0.0),0.75),2.0),5)),
with_variable('poly_perimeter',perimeter(geometry(get_feature('POLY_LAYER','id',33))),
round(@points_perimeter,1) || ' m (' || round(@points_perimeter / @poly_perimeter * 100,2) || '%)'))

Just replace the id and value in the get_feature expression with a unique field and value for your layer.

If there can be multiple features in the 'POLY_LAYER' then that expression will need to be enhanced.

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