[GRASS5] r.mapcalc bug/64bit?

Markus Neteler neteler at itc.it
Tue May 2 15:12:43 EDT 2006


On Tue, May 02, 2006 at 06:24:09PM +0100, Glynn Clements wrote:
> 
> Markus Neteler wrote:
> 
> > > What does the following say:
> > > 
> > > r.mapcalc 'test = isnull(modis_t_a_lst1km20040102.daily_min) + isnull(startday_previous) + isnull(condition_previous)'
> > > r.info -r test
> > > 
> > 
> > This test:
> > 
> > GRASS 6.1.cvs (pat):~ > r.mapcalc 'test = isnull(modis_t_a_lst1km20040102.daily_min) + isnull(startday_previous) + isnull(condition_previous)'
> >  100%
> > GRASS 6.1.cvs (pat):~ > r.info -r test
> > min=1
> > max=3
> 
> The "min=1" means that the value of every cell in the region is null
> in at least one of the three input maps. Consequently, the output map
> will be all nulls.
> 
> Note that the && and || operators follow the same null-propagation
> rules as other operators, i.e. if either argument is null the result
> will be null.
> 
> In particular, the following all evaluate to null, which may be
> counterintuitive:
> 
> 	true  || null
> 	null  || true
> 	false && null
> 	null  && false
> 
> Currently, the behaviour of those operators is:
> 
> 	&&|0 1 N	|||0 1 N
> 	--+-----	--+-----
> 	0 |0 0 N	0 |0 1 N
> 	1 |0 1 N	1 |1 1 N
> 	N |N N N	N |N N N
> 
> Preserving the boolean axioms would give:
> 
> 	&&|0 1 N	|||0 1 N
> 	--+-----	--+-----
> 	0 |0 0 0	0 |0 1 N
> 	1 |0 1 N	1 |1 1 1
> 	N |0 N N	N |N 1 N
> 
> If you want the normal boolean axioms:
> 
> 	true  || x == true
> 	false && x == false
> 
> to hold even when x is null, you can replace && and || with:
> 
> 	x || y -> eval(nx=if(isnull(x),0,x), ny=if(isnull(y),0,y),if(nx||ny,1,x||y))
> 	x && y -> eval(nx=if(isnull(x),1,x), ny=if(isnull(y),1,y),if(!nx||!ny,0,x&&y))
> 
> That's rather messy. If desired, I can re-write the && and ||
> operators accordingly (or add an alternative set of and/or operators).

To maintain the behaviour, the && and || may remain.
To have an alternative set of and/or operators would be pretty good
(and solve my problem!). In fact, doing the eval mess is rather
complicated and error prone.

Looking forward the alternative set,
thanks for the explanation,

 Markus




More information about the grass-dev mailing list