# Using QGIS Raster Calculator with two different rasters

I have several maps like this one:

And with the proximity tool and a coastline shapefile I made this output, representing the distance to shoreline:

Now, I want to combine both using the Raster Calculator. However, everytime that I make an operation, the output is just NaN.

Do you have any hint on why is that?

Solved! Both maps had different projections and the "on the fly reprojection" was activated.

• You are using only Raster Calculator within the toolboxes or you ar adding something more? can you write down your sintaxis in the Raster Calculator? Jan 14, 2015 at 12:21
• I'm only using the Raster Calculator normally. This for example, doesn't work: "Revestimento de Solo@1"*(1/28-0.665*("dist_linha_costa_metros_area_restrita@1"-100)/(4900*22)) Jan 14, 2015 at 13:34
• actually, the distance to shoreline layer don't work with any calculations from Raster Calculator... even "dist_linha_costa_metros_area_restrita@1"-100 does not work Jan 14, 2015 at 14:20
• So how did you end up solving this? Jul 20, 2015 at 3:58

Just a guess but this often happens when the two rasters in different projections.

Try verifying that both share the same coordinate systems.

Did you check the values in your raster, if your operation makes sense? Did you double-check syntax of your expression?

I am always confused about syntax, because I just use raster calculator once in a while. I can just speak from an arcGIS point of view, but there you have a model builder and another tool from toolbox, I think it is called Single Output Map Algebra. Both allow you to just add or subtract a constant to/from your raster, like you did.

Maybe you have similar tools in QGIS you can use alternatively, to prove correctness of our approach, besides syntax? I personally do prefer those over raster calculator.

Hope that helps.

I'm pretty sure that the filename is the problem. 1. Too long 2. contains the "@" character.

• When you already have used the raster calculator in QGIS, you know the "@1" stands for the raster band 1. Jan 14, 2015 at 17:50

Also I had a problem when selecting the extent. QGIS at the moment only updates to the correct extent after you choose the output file.

With an invalid extent I was only obtaining NaN