[gdal-dev]
OGR shapefile driver, field numerical scientific notation
Roger Bivand
Roger.Bivand at nhh.no
Fri Dec 16 12:47:11 EST 2011
Hi,
I've been contacted off-list by users of OGR and shapelib compiled into R
packages. They report recent ESRI shapefiles apparently writing very small
floating point numbers in "e" format, which can be read but not be written
with shapelib or the ESRI shapefile driver. The numbers were generated by
computation on field values, some of which could be smaller than 1e-20.
Their suggested resolution was to edit line 1347-8 in:
http://trac.osgeo.org/gdal/browser/trunk/gdal/ogr/ogrsf_frmts/shape/dbfopen.c
sprintf( szFormat, "%%%d.%df",
nWidth, psDBF->panFieldDecimals[iField] );
to accommodate a possible scientific notation. I did ask for example
files, but they are content to use a locally modified shapelib.
Does anyone have access to ArcGIS to see what ends up in the DBF file, and
thus create a test case? It seems that the function reading the DBF in
shapelib and the OGR driver works OK, but what the value cannot be written
out again. I can confirm from R that the value written out in the OGR
driver for 1e-20 is read in again as 0. If a test case can be constructed,
I'd be willing to file a bug/wish report and help see what could be done.
I realise that ESRI are probably stretching what may be put into a DBF,
but if they are doing this, it might be reasonable to do the same.
Best wishes,
Roger
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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 gdal-dev
mailing list