[GRASS-dev] Re: [GRASS5] r.mapcalc bug/64bit?
Glynn Clements
glynn at gclements.plus.com
Thu May 4 21:23:54 EDT 2006
Markus Neteler wrote:
> > Also note that the r.info commands indicates that condition and
> > condition_previous only contain 1 or null, so the logic can be
> > simplified to:
> >
> > cp=N cp=1
> > c=N N N
> > c=1 N d+1
> >
> > Thus the output cell will only be null if all three input cells are
> > non-null.
Sorry, that should have read:
Thus the output cell will only be NON-NULL if all three input
cells are non-null.
> The last sentence I don't understand (sorry for being slow on this).
> If all input is 1, I expect to get 2 as result (at least that's my
> wish).
>
> Simplified:
> r.mapcalc 'duration=if(condition == 1, if(condition_previous == 1, duration + 1, 1), duration)'
>
> So: if c==1 and cp==1, why not d=d+1=2 ?
>
> From your simplified table I would also expect this result.
d+1 is only 2 if d is 1. If d is null, it d+1 is null.
IOW, if c==1 and cp==1 and d==1, then the result is 2. But that's
three different conditions which have to be met. The other 7 possible
combinations all result in null. Unless there's at least one cell
where the non-null portions of all three input maps overlap, the
output will be all-null.
Try:
r.mapcalc 'temp = isnull(condition) + isnull(condition_previous) + isnull(duration)'
r.info -r temp
If the minimum value for temp isn't zero, then every cell is null in
at least one of the three input maps, and thus the output will be
all-null.
More generally, I find the fact that all of your input maps contain
only null and 1 rather odd. That, and the fact that you are testing
whether startday_previous and condition_previous are equal to zero
suggest that something is using null where you really want zero.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list