I have two similar rasters of the Mount Vesuvius and surroundings: one spans 20 kilometers, and the other one 50 kilometers. The two rasters are overlapping:

enter image description here

What I would like to do is to create a new raster file which will show the difference in elevation between these two rasters. I tried using the Raster calculator with the following expression:

"vesuvius_radius_20KM@1" - "vesuvius_radius_50KM@1"

enter image description here

But for some reason it does not work. After I press OK, all I get is some sort of black raster file which does not have any kind of elevation data in it, nor it has any number of pixels:

enter image description here

What am I doing wrong, and how can I create a raster file which will show the difference between the upper mentioned two raster files?

Here are those two raster files:

https://www.dropbox.com/s/98hcftjsnmrqs8p/vesuvius_radius_20KM.tif?dl=0 https://www.dropbox.com/s/a68921e6tpszt0f/vesuvius_radius_50KM.tif?dl=0

2 Answers 2


Oh will you feel silly! ;-)

The result is actually correct. The two rasters are identical where they overlap. Where they do not, the result is NaN because you cannot do math with a non-existent value.

  • 3
    Thank you for the quick reply and explanation bugmenot123. I do feel silly.
    – marco
    May 7, 2016 at 23:49

I´m not quite sure,if what bugmeont suggested is correct. I guess if both layers are equal the outcome of the new one should be a layer with zeros and not with no-data values.

edit: also yourpicture shows 0 there, where there is no overlap and NaN where you have overlap, which also does not fit to the explanation.

  • Hi @Philipp Dahlem. Thank you for the reply. I am not sure I understood the first part of your reply. Can you try to download the both .tif files please? As for the second one: you are correct. It's definitively a bug in QGIS: the 'nan' should be depicted with white rectangle, and '0' should be depicted with black rectangle
    – marco
    May 8, 2016 at 16:13

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.