[GRASS-user] r.mapcalc help

Chris Carleton w_chris_carleton at hotmail.com
Sat Feb 26 11:48:21 EST 2011


Thanks Glynn. My solution has been to do as you say with some
modifications and the result looks good. I changed the small
buffer-circle maps from 1 and nulls to binary rasters so that I can
avoid dealing with nulls. I also stopped using the same map as output
and input. It was easier to work out the conditional statement without
the nulls.

Chris

On 26 February 2011 00:59, Glynn Clements <glynn at gclements.plus.com> wrote:
>
> 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