5

Using the shortest_line function conditioned to a table attribute to return the shortest line joining features of the same layer as it shows in this expresion:

shortest_line(
    $geometry,
    aggregate(
        'PROP',
        'collect',
        $geometry,
        "VALUE" = '2'
    )
)

1

Is there any solution to count the number of features that are joined to each point and place a dynamically label?

I have prepared the following expression using the array_length and overlay_nearest functions which does not work satisfactorily as you can see in the screenshot:

CASE
    WHEN "VALOR"=2 
    THEN 
    array_length(
        overlay_nearest(
            'PROP',
            $id,
            limit:=8,
            max_distance:=7
        )
    ) - 1
    ELSE NULL
END

2

1
  • providing sample data would help
    – Babel
    Dec 30, 2022 at 10:15

1 Answer 1

5

Use this expression:

count(
    $id, 
    group_by:=overlay_nearest ('PROP', $id, "VALOR" = 2)[0]
)-1

This returns to how many other points each point with VALOR=2 is connected. The point itself is not counted. If you want to count it as well, simply delete -1 at the end of the expression.

enter image description here

0

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.