1
  • I have a point layer "Layer1", with an attribute called L1_att.
  • I have a surface layer "Layer2", with an attribute called L2_att.

In my symbology of Layer1, I have categorized with L1_att. I have a point symbol (different color for each value) and also a "geometry generator" with type as surface.

For the geometry generator part, what I'm trying to do is something like this:

collect_geometries(overlay_intersects('Layer2', 'L2_att'="L1_att",$geometry))

This means, I want to collect the polygons that overlay my point layer, but only if their attributes are the same! And secondly, if a polygon covers 2 points, does it show this feature twice? Cause I want it to be shown only once.

Hope it is clear enough!

EDIT: I try Babel's solution (see below), but it doesn't seem to work: enter image description here

1 Answer 1

2

Edit: new version

Use this expression:

geometry (
    get_feature_by_id (
        'Layer2',
        array_first (
            if (
                L1_att = array_first (overlay_intersects('Layer2', L2_att)),
                overlay_intersects('Layer2', $id),
                ''
))))

Screenshot: point X is inside polygon X and polygon Y, but only polygon X is created with Geoemtry generator, based on the common attribute value X: enter image description here

Old version

Use this expression:

collect_geometries (
    if (
        L1_att = array_first (overlay_intersects('Layer2', L2_att)),
        overlay_intersects('Layer2', $geometry),
        ''
))
10
  • It doesn't seem to work! I had a screenshot above. I should have only 4 different colors, with same transparentcy. But I have feature that are represented multiple times (red feature at South is present 7x times), and with different colors (big feature on the North should only be red but it's also purple and green)!?!
    – katagena
    Sep 22, 2021 at 6:20
  • OK, so probably I don't understand exactly how your result should look like. Can you add a screenshot that shows what you want to achieve? Or add more information.
    – Babel
    Sep 22, 2021 at 7:07
  • Multiple features: yes, for each point that fulfills the condition, you get a separate feature. If you use Geometry by expression, you can then run Delete duplicate geometries.
    – Babel
    Sep 22, 2021 at 7:08
  • I'm trying to find a more "straight forward" solution for the question here: gis.stackexchange.com/questions/412023/…
    – katagena
    Sep 22, 2021 at 7:23
  • My problem is if I use "geometry by expression", I have a new layer... but I don't want that.
    – katagena
    Sep 22, 2021 at 7:25

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.