I have a normalised dataset of Europe that has significant gaps in the UK and Scandinavia (raster1). The nodata value for raster1 is 2.54. To fill those gaps I want to use another normalised European dataset that shows the same information, but is a bit older (raster 2). Importantly, this raster has data gaps for large parts of Eastern Europe. I used raster calculator for this, doing the following:

("raster1" > 1) * "raster2" + ("raster1" <= 1) * "raster1"

As I understand, this should fill all cells above 1 with the values from raster2, and maintain the raster1 values for all cells below 1.

My output file seems to do just that, BUT it seems that QGIS somehow clips raster1 by raster2 in the process and while the gaps in the UK and Scandinavia are filled in my output, the output now has raster2's gaps in Eastern Europe.

Is there any way I can only fill the gaps in raster1 without losing the data that raster2 is missing?

1 Answer 1


I think it's better to fill the NODATA value from raster1 using value from raster2.

Using the IF function in raster calculator (from QGIS => 3.22) with the value from band 1:

IF("raster1@1" = 2.54, "raster2@1", "raster1@1")

This should only process the raster1 only if the value of the pixel is equal to 2.54. You should check for differing raster resolutions and verify that the boundary between NODATA in raster1 is all filled correctly.

  • Hi @ConfusedButterfly! Thanks for your answer, I tried it like this and the output raster ranges from 0 - 2.54, so the no data value was not overwritten with the raster2 data it seems? Or could that be because not all of raster1's nodata values are covered by raster2?
    – geogalog
    Commented Oct 14, 2022 at 11:05
  • @geogalog try IF("raster1@1" = 2.54, IF(( "raster2@1" >= 0) AND ("raster2@1" <=1)), "raster2@1", 99), "raster1@1") if there is a cell with value of 99 in the output layer then you have a missing data both in raster1 and raster2. That formula will fill the output layer with raster2@1 only if raster2@1 is between 0 and 1. From there you can further troubleshoot the problem. Commented Oct 14, 2022 at 11:34
  • @geogalog also try to read this gis.stackexchange.com/a/259934/180989, maybe your problem arises from differing raster resolution? Commented Oct 14, 2022 at 11:41
  • Thanks a lot @ConfusedButterfly! It turns out indeed there are missing data cells in both layers, so I will have to find a different dataset to fill those.
    – geogalog
    Commented Oct 17, 2022 at 13:16
  • @geogalog in a pinch, you can use interpolation to fill the missing data. Try to consult an existing publication for the "best" method for your specific data. Commented Oct 18, 2022 at 7:13

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.