3

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.

merged

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:

DEM A Buildings B

A = DEM

B = Buildings

if(B>A,A+10,A) 
2
  • 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
4

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"

and select output layer as C.tif.

I tested it with two arbitrary random raster and it worked as expected. It was corroborated by using Value Tool QGIS plugin.

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.