10

Given a point geometries collection, I would like to use an expression which:

  1. Find the 4 points nearest to each other
  2. Create the buffer for each group of 4 points with the radius distance value corresponding to mean distance to the 4 nearest points.

I add a screenshot representing the expected result:

enter image description here

4
  • 3
    So, since you have an expression... what is your question?
    – Erik
    Commented Apr 4, 2023 at 11:25
  • 1
    What does not work with your expression which seems to be a good start? Rather than buffer you can make_circle(...)
    – Kasper
    Commented Apr 4, 2023 at 11:29
  • 1
    This is for visualization purpose, or you need a individual buffer layer? Commented Apr 4, 2023 at 11:55
  • Visualization purpose
    – Acperience
    Commented Apr 4, 2023 at 12:12

1 Answer 1

13

You can use this expression:

buffer(
    $geometry,
    array_mean(  -- lengths mean
        array_foreach(
            overlay_nearest( -- get nearest points
                'CONTENIDORS_GEO',
                $geometry,
                limit:=4
            ),
            length(
                make_line(
                    $geometry,
                    @element
                )
            )
        )
    )   
)

enter image description here

1
  • 3
    So basically OP had it correct, except for the outermost part of the expression?
    – Erik
    Commented Apr 4, 2023 at 12:01

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.