[GRASS-user] v.out.ascii output is different than the original ascii raster

Roger Bivand Roger.Bivand at nhh.no
Sun May 21 17:09:14 EDT 2006


On Sun, 21 May 2006, Maciek Sieczka wrote:

> Hi,
> 
> I've got double floating point Grass ASCII raster (dem.asc, attached).
> 
> I do:
> 
> 	r.in.ascii -d input=dem.asc output=dem
> 
> 	r.out.ascii input=dem output=dem2.asc
> 
> and compare dem.asc vs dem2.asc, to notice that all values in dem2.asc
> (attached) are slightly different (sometimes lower, sometimes higher).
> 
> Eg. the first floating point value in dem.asc is:
> 
> 	104.999999999197
> 
> while in dem2.asc it's:
> 
> 	104.9999999991970014
> 
> The 2nd one in dem.asc:
> 
> 	104.999999999756
> 
> and the 2nd in dem2.asc:
> 
> 	104.9999999997559996
> 
> And so on, all of them. Why aren't they equal?
> 
> I'm using r.out.ascii and r.in.ascii in a script to interface with
> external program and I would expect Grass to preserve exact values.
> 
> A bug?

No, the result of representing the input ASCII as a double (which will 
include fuzz), and writing it out with more digits of fuzz. The R FAQ sums 
it up nicely:

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

or a link refered to there:

http://docs.sun.com/source/806-3568/ncg_goldberg.html

To a computer using 64 bits for a double, both will look the same within 
machine precision, so the tiny difference should have no practical impact.

Hope this helps,

Roger

> 
> Maciek
> 
> 
> --------------------
> W polskim Internecie s? setki milion?w stron. My przekazujemy Tobie tylko najlepsze z nich!
> http://katalog.panoramainternetu.pl/
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the grass-user mailing list