# GRASS 7 - raster calculator “and”

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

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: • Gene, thank you - that is the solution! Highly apprieciated! – Peter Sep 20 '13 at 6:46