2

I would like to use a set of rules to draw features from a point_layer that are within a polygon_layer.

Points that answer true to

("VAL_PROTECTION_EP3" = '1' AND  "TYPE"  = 1) 

and that are within polygons that answer true to

("TYPE" in ('P','E') AND "CAT_CANTON" = 2) OR ("TYPE" in ('P','E') AND "CAT_CANTON" = 3)

should be displayed as red dots

Points that answer true to

("VAL_PROTECTION_EP3" = '2' AND  "TYPE"  = 1) 

and that are within polygons that answer true to

("TYPE" in ('P','E') AND "CAT_CANTON" = 2) OR ("TYPE" in ('P','E') AND "CAT_CANTON" = 3)

should be displayed as orange dots

Points that answer true to

("VAL_PROTECTION_EP3" = '3' AND  "TYPE"  = 1)

and that are within polygons that answer true to

("TYPE" in ('P','E') AND "CAT_CANTON" = 1)

should be displayed as yellow dots

I cannot find the right combination of expressions for the rule to work.

What would a working syntax be for such a rule to work in QGIS Layer Styling panel ?

2
  • Could you perhaps share the file so I can test it? Aug 30 at 11:44
  • I can't share the data, sorry.
    – CedricJ
    Aug 30 at 13:15
4

Depends on your QGIS version, from 3.16 onwards you can use the overlay-functions to proof if the point and polygonlayer are in a spatial relation like intersects or touches and so on. The expression for your first rule will be like this one:

"VAL_PROTECTION_EP3" = '1' AND  "TYPE"  = 1 AND  
overlay_intersects(   layer:='pol', 
    filter := ("TYPE" in ('P','E') AND "CAT_CANTON" = 2) OR ("TYPE" in ('P','E') AND "CAT_CANTON" = 3))

In the overlay_intersects-part you have to change the layername to your polygon layer.

If you have an older QGIS Version you can achieve the more or less same result with the refFunctions Plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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