# Raster calculator - if statement

I'm fairly new to QGIS, but I'm getting the hang of it. I have two layers - one DEM and one raster made from shape file (Buildings), but need one with higher Elevation where the buildings are for terraflow. But I can't seem to get the raster calculator to work with if Statement. I found a Workaround by assigning a fixed elevation value to the building raster, that is higher than any Point on DEM.

But on DEMs with high Elevation difference this means that some Buildings are over 50m tall!!! would like to make an if statement like this:

A B

``````A = DEM

B = Buildings

if(B>A,A+10,A)
``````
• You can use the GRASS raster calculator, accessible via the QGIS processing toolbox. It has an `ifelse` condition you can use: gis.stackexchange.com/questions/110248/… – Babel Jan 29 at 13:38
• QGIS raster calculator uses a different logic for if statements. Please, see my answer. – xunilk Jan 30 at 16:44

QGIS raster calculator uses a different logic for if statements. For implementing this expression `if(B>A,A+10,A)`, you need to write in Raster Calculator Expression Window following formula:
``````( "B@1" >  "A@1" )  *  ( "A@1" + 10 ) + ( "B@1" <= "A@1" ) * "A@1"