4

I am trying to get the saga raster calculator in QGIS to spit out all values of a raster that are inferior to 10, and make all other values zero. I think the syntax is correct but I keep getting the original raster as an output which is definitely not what I want. Here is the code I am using:

    ifelse(lt(a,10),a,0)

I'm thinking there must be a problem with the way I am referencing the raster? I read in the SAGA help pdf that "if you have four grid map layers in your ‘Input’ list, they will be referred to by a, b, c, and d." So I'm not sure what I'm doing wrong.

2 Answers 2

5

I think the SAGA help file is outdated? a,b,c, was replaced by g1, g2, g3, etc. I tried in SAGA directly using the Grid calculator module and it worked with using the formula:

ifelse(lt(g1,10),g1,0)

Hope that helps also in QGIS!

5

lt(a,10) returns 1.0 if a < 10 is true (else 0.0).

You can use either ifelse() or lt(), but not together.

ifelse(a < 10, a, 0)

and

lt(a, 10) * a

will both work.

Note: a and g1 both means the first input grid. You can use either a, b, c, ... or g1, g2, g3, ...

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.