[Gdal-dev] Ogr2ogr shapefile to postgis precision problem

Frank Warmerdam fwarmerdam at gmail.com
Mon Mar 14 10:23:00 EST 2005

On Mon, 14 Mar 2005 15:35:13 +0100, Asger Petersen
<asger at jo-informatik.dk> wrote:
> Hi
> I'm having some problems regarding attribute integer precision when
> converting shapefiles to postgis tables.
> I have a column named ("ID") which ArcGIS reports as "double(15,0)", and
> it holds only positive integers with 15 digits (like: 12080000240330).
> Ogr2ogr maps this column to "numeric(15)" in postgres, but the values it
> actually puts into the table are negative and only 10 digits (like:
> -1742763318).
> Can anyone tell me what I am doing wrong, and how to get these values
> correctly into postgres?


The problem is that you have an effectively integer field with values 
larger than can be held in a 32bit integer.  This is quite a painful 
case for OGR.  

I have just committed a small change that should allow the Shapefile
driver to treat fields wider than 10 digits with no decimal places as
type double instead of integer.  This should get the values into OGR
properly but I am not certain that the result wll make it into PostGIS

Could you file a bug report with a sample dataset (hopefuly just a few
records) that demonstrates this problem? 

Finally, your safest bet would likely be to split the ID field into 
two fields in ArcGIS.  

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

More information about the Gdal-dev mailing list