[GRASS-dev] r.univar: 'nan' results

Martin Landa landa.martin at gmail.com
Sun Sep 17 12:50:25 EDT 2006


Hi,

in do_lines.c, the function v2angle ()

/* cos of the angle between two vectors is (a . b)/|a||b| */
double
v2angle(double v1[2], double v2[2], double mag1, double mag2)
{
    double costheta = (v1[0] * v2[0] + v1[1] * v2[1])/(mag1 * mag2);

    return (acos(costheta));
}

If mag2 is 0 you get 'nan' value. Not sure, just testing...

if (mag2 == 0)
-> cat value NULL

?

Martin

2006/9/17, Maciej Sieczka <tutey at o2.pl>:
> Martin Landa wrote:
>
> > Hamish wrote:
>
> >> (nan = not a number, GRASS uses NULL for the same idea, but NULL is not
> >> the same as nan.)
>
> > agreed, for me, it seems like a bug (v.to.rast?), in any case a 'nan'
> > value is an *invalid* cell value.
>
> >> If there are nan in the cell data, the r.univar calculations can't cope.
> >> The question is: how did nan cells get into the input raster map?
>
> > v.to.rast ?
>
> >> There is a possibility that there is a bug in r.univar..
> >> Try using r.mapcalc to isolate the nans? What does "r.info -r" say?
>
> > min=0.000000
> > max=358.264295
>
> It seems like a bug in v.to.rast. Take the location I attached, and do:
>
> $ g.region vect=cieki10_2zl res=10 -a
> $ v.to.rast input=cieki10_2zl output=cieki10_2zl_dir use=dir
>
> There are several nan cells indeed:
>
> $ r.stats -1g cieki10_2zl_dir | grep -i nan
> r.stats: 600265 5680715 nan
> 600335 5680575 nan
> 600395 5680435 nan
> 599735 5680345 nan
> 598695 5679865 nan
> 600245 5679475 nan
> 599125 5679245 nan
> 599675 5678955 nan
> 598915 5678935 nan
> 599815 5678765 nan
> 598785 5678655 nan
> 600345 5678335 nan
> 600545 5678015 nan
>
> Maciek
>
>
>


-- 
Martin Landa <landa.martin at gmail.com> * http://gama.fsv.cvut.cz/~landa *




More information about the grass-dev mailing list