Skip to content

decimal places of coordinates get lost - readGDAL

2 messages · Tim.Haering at lwf.bayern.de, Roger Bivand

#
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?
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
#
On Mon, 19 Jul 2010, Tim.Haering at lwf.bayern.de wrote:

            
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