I have a vector layer of buildings:

enter image description here

and a polygon layer coloured by some quantity:

enter image description here

and I want to mask one by the other to produce this:

enter image description here

This can be done by setting the blend mode to "Multiply" with the building polygons on top as long as the polygons are white and the background of that layer is black.

One way of doing that is to use an "Inverted Polygons" fill but that is very slow at low zoom levels since all the buildings are in view and that's a lot of inverted polygons.

The other way I thought I'd cracked this was to create a "Group" layer with the buildings filled in white and a virtual layer consisting of the bounding box of the buldings filled in black. On its own it looks right:

enter image description here

but QGIS (3.6) doesn't let you blend grouped layers (Gimp and Photoshop probably do) so it doesn't work.

I really want to do it in the canvas so solutions involving processing intersections and creating new layers and so on aren't going to work either.

I'm not sure if I'm missing a trick to create a style for a layer to have a black background, or if there's something else in the blending modes that will do this...

2 Answers 2


You can put the colored polygons on top, with a layer blending mode set to darken

Below, have the building layer with the polygon fill in white.

At the bottom, add a new layer containing one large black polygon.

enter image description here

Without the black background:

enter image description here

  • Bingo. Polygons on top just didn't occur to me! I can use my virtual bounding box layer as the black background.
    – Spacedman
    Commented Apr 1, 2019 at 17:18

Here's an alternate method for coloring the colored buildings to match the underlying zones.

With Geometry Generator styling, create a separate symbol layer of buildings that intersect each of the zones.

intersection($geometry, geometry(get_feature( 'zones', 'zoneNo', 1)))
intersection($geometry, geometry(get_feature( 'zones', 'zoneNo', 2)))

enter image description here

Change the color of each symbol layer to match the zone color. Create a black background, eg by setting the map canvas background color to black, or by changing the zone layer style to black-filled simple polygons.

enter image description here

Disclaimer: My test dataset was very small, so I have no idea if this will render faster than the inverted polygon method.

  • That looks a bit long-winded for general use, but possibly useful in some instances... thanks.
    – Spacedman
    Commented Apr 1, 2019 at 17:19

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.