[GRASS-user] r.mapcalc help

Glynn Clements glynn at gclements.plus.com
Sat Feb 26 00:59:17 EST 2011

Chris Carleton wrote:

> ###the problematic r.mapcalc operation is below###
> subprocess.call([
> 	"r.mapcalc",
> 	"B = if(!isnull(A) && temp_rast_focus_ <= B,A,B"])

1. Don't use the same map for both input and output.

2. If either temp_rast_focus_ or B are null, the result will be null. 

Except for specific cases, nulls propagate, i.e. if any operand is
null the result will be null. isnull() is an exception, but && isn't
(i.e. "0 && null()" is null, not 0). You might want to use the &&&
operator instead, which satisfies "0 &&& x == 0" and "x &&& 0 == 0"
even when x is null.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list