4

I display the labels of a point layer (layer "q"). With a command found on the site, I know how to filter the labels if they intersect an object from another layer (layer "p1"). On the other hand, when there are several objects it no longer works (layer "p2").

Does anyone have an idea for a recursive filter?

The expression I tried:

case
when intersects ($geometry, geometry (get_feature ('p2', 'ccogrm',4)))
then 1 
else 0
end

enter image description here enter image description here enter image description here enter image description here enter image description here

0

1 Answer 1

7

To only show labels that intersect with layer p1 or layer p2, use this expression in Placement tab for data defined Show label setting:

overlay_intersects ('p1') or overlay_intersects ('p2')

Only points intersecting layer p1 (blue) or p2 (yellow) are labeled: enter image description here

To include all polygon layers in the project and to avoid repeating layer1 or layer2 etc., use this expression that includes automatically all layers of type polygon:

array_contains(
    array_foreach(
        array_foreach (
            @layers,
            if (
                layer_property (@element,'geometry_type') = 'Polygon',
                @element,
                @layer
            )
        ),
        overlay_intersects (@element)
    ), 
    true
)

Each polygon is a different layer. Only points that overlap one of the polygon layers are labeled, based on the expression above:

enter image description here

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.