QGIS 3 – Using Both Standard and Inverted Polygon Symbology on a Single Layer

geometry-generatorqgis-3symbology

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

Best Answer

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

Related Question