QGIS – Overlaying Binary Raster Over Colorized Raster Layer Without Affecting Color

mergeqgisrasterraster-calculator

I'm looking to merge a raster layer of bounding boxes over top a standard RGB raster layer so that the boxes fit over certain features in the background raster, but they are now the same layer. The boxes are black (binarized), so the boxes should look black over the colour photo.

I've tried raster -> merge with each of the RGB bands plus the box layer, but it doesn't work. I've also messed around with raster calculator. I tried to make it so the box outlines were '0' and then multiplied that layer by the bands from the RGB photo, so the underlaying pixels would be black when merged back together, however, this doesn't seem to work.

This is what the output should look like -again- as one layer:

black boxes over RGB

Best Answer

  1. When rasterizing, set Assign a specified nodata value to output bands to Not set (instead of 0 as you have it). It will result in a raster with your boxes in white (value = 1) and the rest of the raster in black (value = 0) instead of no data.

  2. Use the raster calculator and multiply the rasterized layer with the RGB raster layer. However, the values of the rasterized layer should be turned: box should become 0, rest become 1. Use this formula: ABS ( "Rasterized@1" -1)

  3. Multiply this with each band of your RGB raster, than stick the three outputs together.

enter image description here

Related Question