2

I tried to use comparisons as conditional statements in QGIS 2.4.0 raster calculator.

My statement is:

(a < 230) * 230 + (a >= 230) * a

The expected result is raster a with all values lower than 230 replaced by 230.

What I get instead is a raster with nan and 3.40282e+38.

Upon further investigation I found that the comparison returns either 1 or nan / -3.40282e+38. Why is it not returning 1 or 0? What am I doing wrong? How can I build conditional statements with the raster calculator?

  • Your statement seems fine, it may be a problem with the raster layer itself. How was your raster created? – Joseph Oct 1 '14 at 14:56
  • I got point elevation data in some weird custom Japanese CRS which I interpolated via Raster->Analysis->Grid, then warped into WGS 84 and clipped to get a clean raster. This hints at a workaround using Saga or ASCII rasters. Still I am curious why this behaviour occurs. – sedot Oct 1 '14 at 14:59
  • 1
    Do you get the same result if you manually change the CRS before you interpolate and clip? – Joseph Oct 1 '14 at 15:29
  • 1
    Sorry Joseph, I forgot to answer this because I found another solution for my general problem. But it might be good to know that this is resolved as of QGIS 2.12.0. Everything works as expected. Thanks for your effort! – sedot Nov 28 '15 at 17:01
  • Don't worry about it buddy, you're only over a year late! :). But glad you got it working, you should post how you solved it as an answer to close this question off. – Joseph Nov 30 '15 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.