[R-sig-Geo] decimal places of coordinates get lost - readGDAL
Roger Bivand
Roger.Bivand at nhh.no
Mon Jul 19 13:55:07 CEST 2010
On Mon, 19 Jul 2010, Tim.Haering at lwf.bayern.de wrote:
> Hello !
>
> I want to import a raster into R using the readGDAL() function.
> Unfortunately the coordinates of my raster have decimal places. After
> importing the file the decimal places get lost. It seems the GDAL rounds
> the coordinates. Is it possible to read the decimal places?
Try setting a different value for options("digits") to be used by the
print() method you are calling invisibly. Showing a floating point number
must involve arbitrary rounding, and if you haven't specified a different
number of digits, you get the default:
x <- 4344198.9375000019
print(x)
print(x, digits=16)
print(x, digits=20)
Notice that your example number cannot be represented in double precision,
as after 4344198.93750001 there is no precision left, and any operations
(such as multiplication) will erode it anyway. In any case, you are
probably dealing with a missing part of the size of 0.0000019 mm, which
might just be more precise than the measurements were.
Hope this clarifies,
Roger
> Here a little example:
> The header of my ASCII file:
> NCOLS 202
> NROWS 201
> XLLCENTER 4344198.9375000019
> YLLCENTER 5537700.3750000028
> CELLSIZE 20.000000
> NODATA_VALUE -99999
>
> myraster <- readGDAL("raster.asc")
> myraster at coords
> x y
> [1,] 4344199 5537700
> [2,] 4348219 5541700
>
> Thank you.
>
> TIM
>
>
> -----------------
> Tim Häring
> Bavarian State Institute of Forestry
> Department of Forest Ecology
> Hans-Carl-von-Carlowitz-Platz 1
> D-85354 Freising
>
> E-Mail: tim.haering at lwf.bayern.de
> http://www.lwf.bayern.de
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
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 R-sig-Geo
mailing list