I have a raster A (a heightmap created from a contour file). I also have created a vector layer with some polygons which I rasterized into raster B. Raster B is completely contained within the extents of raster A.
Raster A has values at each pixel. Raster B, on the other hand, has a bunch of empty area (which I believe is represented as 0 or nodata).
I'd like to produce raster C, such that C = A + B, where A and B intersect, and C = A where A and B don't intersect.
The problem I'm running into is that when I add the two rasters together using the raster calculator, the result only has values where the two rasters intersect, but show nothing where they do not intersect. I'm guessing this is due to how QGIS treats nodata values.
How can I achieve what I'm trying to do?
Best Answer
The problem, as you observed, is that the Rasterize program sets the values outside of the polygons to NODATA (or dummy), and the raster calculator outputs a dummy wherever either raster has a dummy. In QGIS 3.6.3 I've solved this problem by specifying the output carefully in the Rasterize program to give everything outside of the polygons a value of zero.