5

I have two raster (raster1 and raster2) from the same area. I would like to make the sum between the two (raster3 = raster1 + raster2) in QGIS, so that the Digital Number (DN) of raster 3 is the sum between them. However, raster2 has some pixels like "nodata" or "null" without data. When I add them together, the "nodata" pixels do not add up.

For example: raster1 = 2 and raster2 = nodata. When I add these, the result is nodata (2 + nodata = nodata), but I expected it to be = 2, that is, (2 + nodata = 2).

How could I solve this problem?

4

You start QGIS with GRASS and then run r.null from processing toolbox on your nodata raster and convert all NULL values to 0 values. Then you should be able to build your sum in raster calculator.

enter image description here

enter image description here

3
  • hello @MrXsquared, i tried apply you answer, but not the result yet returns pixels with nodata. – wesleysc352 Dec 19 '20 at 14:15
  • 1
    @wesleysc352 That shouldnt be the case. I have attached a short GIF to illustrate. – MrXsquared Dec 19 '20 at 14:37
  • 1
    hello @MrXsquared,thanks for the immense help. I had filled in the wrong field. Now it worked. – wesleysc352 Dec 19 '20 at 15:08
1

I would note that the GRASS module r.mapcalc allows you to add rasters, while ignoring NULL cells, without changing the original. For example:

r.mapcalc "raster3 = if(isnull(raster1), raster2, raster1 + raster2)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.