3

I have multiple polygon shapefiles, each containing several features with a single attribute, given a value of either 0 or 1. The "1" features show areas of interest. There are often "0" features situated within these areas to denote smaller areas that are not within the study area.

I'm looking to style each layer using QGIS 3.x such that the 1 features use inverted polygons to draw attention away from the areas outside each polygon and highlight the study area, whilst the 0 features are displayed with a fill inside the polygon to remove these areas. Is this possible, perhaps through using the geometry generator?

I'm aware that I could use the erase tool or similar to cut the 0 features out, but I'm looking to acheive this using symbology alone if possible. I don't have control over the structure of this data as it is required for input to a separate model.

Edit: I've added a screenshot created using multiple layers to acheive the effect I'm aiming for - each polygon labelled.

Example symbology

7
  • Just to clarify you want to have the "1" feature as inverted polygon but not covering the area of "0" polygon ?
    – J.R
    Commented Dec 14, 2022 at 14:01
  • Yes. I've added a screenshot created using two separate dummy shapefiles to illustrate what I'm aiming for. The 0 polygons should always be within the 1 polygons, so I'm just after a way to invert the 1 polygons, but not the 0 polygons within the same layer/symbology. Commented Dec 14, 2022 at 14:15
  • 2
    I don't understand: if you style the layer with the two features 1 (large) and 0 (small, inside of 1) with inverted polygons, then everything will be covered, expect the part of of polygon 1 that is not covered by polygon 0 - thus exactly what you want. So I don't undestand either the question or your data structure. Can you provide A) sample data nnd B) show how exactly the result should look like?
    – Babel
    Commented Dec 14, 2022 at 14:29
  • If you use a definition query to limit your layer to 1, then apply the inverted polygon, does that work? If you still need to label 1 and 0 you can use a duplicated layer.
    – John
    Commented Dec 14, 2022 at 15:14
  • 1
    Thanks, folks. Babel - it looks like I was being too clever with the symbologies and trying to use the "sub renderer" option set to rule-based to apply different symbologies to the 0 and 1 polygons. Just using the basic inverted polygons option as you suggest seems to do the trick! If you post that as an answer I'll accept and comment. Thanks. Commented Dec 15, 2022 at 9:18

1 Answer 1

3

If you style the layer with the two features 1 (large) and 0 (small, inside of 1) with inverted polygons, then everything will be covered, expect the part of of polygon 1 that is not covered by polygon 0 - thus exactly what you want.

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.