1

I am struggling with one thing in the raster calculator in GRASS GIS 7: I want to create a raster_b from raster_a, with raster_a values between >=-0.15 and <=0.15. The raster containing values <-0.15 I calculated with if("raster_a" >0.05 , raster_b, null()),

but how do If((raster_a >-0.15) and (raster_a <0.15), raster_b, null))?

Any help is appreciated! Peter

  • I can't say for sure, because I don't use GRASS, but if it's calculator is like the one in Whitebox GAT then, your statement would have to be: If(AND((raster_a >-0.15), (raster_a <0.15)), raster_b, null)) – user21951 Sep 19 '13 at 16:00
3

The formulation is (for GRASS 6.x and GRASS 7):

if expression = True -> value of raster_a  
if expression = False -> nothing (null())

and:

resulting_layer = (expression, True, False)

so:

raster_b = (if..., raster_a, null())
  • In the GRASS shell:

    r.mapcalc 'raster_b = if(raster_a > -0.15 && raster_a <0.15 ,raster_a,null())'

  • with the Raster Map Calculator:

enter image description here

  • Gene, thank you - that is the solution! Highly apprieciated! – Peter Sep 20 '13 at 6:46

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.