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

1 Answer 1

  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

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.