Masking layers by a vector polygon layer in QGISIs there a way to hillshade vector polygons with a DEM in QGIS?Exporting a QGIS layout with Addition on layersTransparency on black/white raster after clipping in QGIS?C++ QGIS Conditional Label ColouringMerge and export two layers that utilize blending modesPyQGIS: vector layer does not get displayed after renderingCan I use a polygon to show a WMS-layer inside while maintaining transparency outside?Calculate Density in QGISCombine raster (monocromatic and RGB image)Creating QGIS map that can be exported and used for 2-colour (spot) printing?
In Romance of the Three Kingdoms why do people still use bamboo sticks when papers are already invented?
Is it unprofessional to ask if a job posting on GlassDoor is real?
Cronab fails because shell path not found
What is the intuition behind short exact sequences of groups; in particular, what is the intuition behind group extensions?
Why is the ratio of two extensive quantities always intensive?
UK: Is there precedent for the governments e-petition site changing the direction of a government decision?
I Accidentally Deleted a Stock Terminal Theme
Anagram holiday
Is it canonical bit space?
If human space travel is limited by the G force vulnerability, is there a way to counter G forces?
What mechanic is there to disable a threat instead of killing it?
Twin primes whose sum is a cube
How do I write bicross product symbols in latex?
Python: return float 1.0 as int 1 but float 1.5 as float 1.5
How can I make my BBEG immortal short of making them a Lich or Vampire?
Facing a paradox: Earnshaw's theorem in one dimension
Neighboring nodes in the network
Blender 2.8 I can't see vertices, edges or faces in edit mode
How to show the equivalence between the regularized regression and their constraint formulas using KKT
Is it possible to download Internet Explorer on my Mac running OS X El Capitan?
How to say in German "enjoying home comforts"
Should I tell management that I intend to leave due to bad software development practices?
How badly should I try to prevent a user from XSSing themselves?
Can a rocket refuel on Mars from water?
Masking layers by a vector polygon layer in QGIS
Is there a way to hillshade vector polygons with a DEM in QGIS?Exporting a QGIS layout with Addition on layersTransparency on black/white raster after clipping in QGIS?C++ QGIS Conditional Label ColouringMerge and export two layers that utilize blending modesPyQGIS: vector layer does not get displayed after renderingCan I use a polygon to show a WMS-layer inside while maintaining transparency outside?Calculate Density in QGISCombine raster (monocromatic and RGB image)Creating QGIS map that can be exported and used for 2-colour (spot) printing?
I have a vector layer of buildings:

and a polygon layer coloured by some quantity:

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

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:

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...
qgis cartography masking
add a comment |
I have a vector layer of buildings:

and a polygon layer coloured by some quantity:

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

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:

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...
qgis cartography masking
add a comment |
I have a vector layer of buildings:

and a polygon layer coloured by some quantity:

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

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:

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...
qgis cartography masking
I have a vector layer of buildings:

and a polygon layer coloured by some quantity:

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

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:

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...
qgis cartography masking
qgis cartography masking
asked Apr 1 at 16:27
SpacedmanSpacedman
24.8k23551
24.8k23551
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.

Without the black background:

Bingo. Polygons on top just didn't occur to me! I can use my virtual bounding box layer as the black background.
– Spacedman
Apr 1 at 17:18
add a comment |
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)))
etc.

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.

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
Apr 1 at 17:19
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317382%2fmasking-layers-by-a-vector-polygon-layer-in-qgis%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.

Without the black background:

Bingo. Polygons on top just didn't occur to me! I can use my virtual bounding box layer as the black background.
– Spacedman
Apr 1 at 17:18
add a comment |
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.

Without the black background:

Bingo. Polygons on top just didn't occur to me! I can use my virtual bounding box layer as the black background.
– Spacedman
Apr 1 at 17:18
add a comment |
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.

Without the black background:

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.

Without the black background:

answered Apr 1 at 16:58
JGHJGH
13.5k21139
13.5k21139
Bingo. Polygons on top just didn't occur to me! I can use my virtual bounding box layer as the black background.
– Spacedman
Apr 1 at 17:18
add a comment |
Bingo. Polygons on top just didn't occur to me! I can use my virtual bounding box layer as the black background.
– Spacedman
Apr 1 at 17:18
Bingo. Polygons on top just didn't occur to me! I can use my virtual bounding box layer as the black background.
– Spacedman
Apr 1 at 17:18
Bingo. Polygons on top just didn't occur to me! I can use my virtual bounding box layer as the black background.
– Spacedman
Apr 1 at 17:18
add a comment |
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)))
etc.

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.

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
Apr 1 at 17:19
add a comment |
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)))
etc.

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.

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
Apr 1 at 17:19
add a comment |
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)))
etc.

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.

Disclaimer: My test dataset was very small, so I have no idea if this will render faster than the inverted polygon method.
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)))
etc.

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.

Disclaimer: My test dataset was very small, so I have no idea if this will render faster than the inverted polygon method.
answered Apr 1 at 16:59
cskcsk
9,6501035
9,6501035
That looks a bit long-winded for general use, but possibly useful in some instances... thanks.
– Spacedman
Apr 1 at 17:19
add a comment |
That looks a bit long-winded for general use, but possibly useful in some instances... thanks.
– Spacedman
Apr 1 at 17:19
That looks a bit long-winded for general use, but possibly useful in some instances... thanks.
– Spacedman
Apr 1 at 17:19
That looks a bit long-winded for general use, but possibly useful in some instances... thanks.
– Spacedman
Apr 1 at 17:19
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317382%2fmasking-layers-by-a-vector-polygon-layer-in-qgis%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown