7

When it comes to NULL value and different extents of rasters I find it extremely cumbersome to use QGIS raster calculator. As far as I am aware there is no way to operate with NaN/Null value. So no matter what you do NaN/NULL in any input become NULL in output.

As far as I am aware you can't do anything like:

(raster1 is NULL)*raster2+(raster1 is not NULL)*raster1

I have similar issue with extents of raster. I have one raster of large extent and second covering only small part of it. I need to update null/zero values of large extent raster to values in small extent raster. If I do calculation below everything off of small extent becomes NULL/Nan.

(largeraster = 0)*smallraster + (largeraster != 0)*largeraster

Is there any way to be able to operate with NULL value in raster calculator? Is there any way to not trash all values in areas where all rasters do not overlap?

  • i think SAGA allows this using 0/0 to represent NaN, e.g. this answer – Steven Kay May 26 '17 at 22:37
  • As to your second question, to replace nodata cells by the values in small extent raster, SAGA Patching tool (in Processing Toolbox | SAGA | Raster Tools) is powerful and reliable. – Kazuhito May 29 '17 at 12:01
  • StevenKay and Kazuhito thank you for your tips, will give it a try – Miro May 30 '17 at 1:09
1

Looking back, your question(s) seems to be about how we fill the void of large raster by a small raster. (I had been thinking two equations in your question were independent).

Using Raster calculator, I think I would suggest a workflow like below:

  1. Change NULL (NoData) of the large raster to 0 (zero).
  2. Merge two rasters (replace zeros of large raster by values from small raster)

(1) Change Null to 0

  • A useful tool is SAGA Reclassify values (QGIS Processing Toolbox | SAGA | Raster tools | Reclassify values).

    We use only replace no data values option. Keep this ticked-on, and set new value for no data values to 0.0 (I think this is default value).

    Make sure replace other values option is off.

    When Run this tool, the NoData cells become 0.

(2) Merge two rasters, only filling voids of large raster

  1. Start Raster calculator

  2. Highlight Large raster on the list and click on Current Layer extent. This will ensure extent of your output.

  3. equation: ("Large@1" != 0) * "Large@1" + ("Large@1" = 0) * "Small@1"

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.