QGIS – Resolve Raster Calculator Output with Mostly NoData Values

nodataqgisrasterraster-calculator

I am using QGIS 3.20 and have an area with the whole extent covered by 4 different layers, but when I perform a raster calculation to sum up the cell values, I only get scattered results in a mostly blank extent. I'm trying with sum and multiply, and the results are similar (except for the values, of course).

"LandUse_rast1@1" + "natvegrast1@1" + "roads_raster1@1" + "water_raster1@1"

Input
Input layers
Output
Output

Best Answer

WHY THIS HAPPENS:

From your screenshots it looks as if some of your layers have cells without data (NA-values). Otherwise it would not be possible to display the layers above each other (unless you have set specific values to be transparent).

If you perform calculations on cells with NA-values e.g. NA + x or NA * x (x being a decimal or integer value) the raster calculator will yield results that are also NA for the given cell.

This is, why you have output for just a few cells - these are cells, where all 4 overlapping layers hold a non-NA value.

WHAT TO DO ABOUT IT:

Depending on the goal of your calculation (not clearly stated). I would recommend you:

  • use the Fill NoData Cells tool. This will replace NA with a given value.
  • If you performe additions fill with 0
  • If you performe multiplications fill with 1
Related Question