[Gdal-dev] ogr2ogr shapefile to postgis error

Frank Warmerdam warmerdam at pobox.com
Thu Sep 30 00:35:02 EDT 2004


Michael Mallete wrote:
> i see. anyway, here's one of the shapefiles from which i encounter
> this problem sir. so for the meantime i'll heed your advice and use
> -skipfailures for the time being. you've been very helpful sir. i
> can't thank you enough. have a wonderful day ahead. :)

Myk,

The "dbfdump" utility reports this:

warmerda at gdal2200[183]% dbfdump -h -r babuyan.dbf | more                        Field 0: Type=Double, Title=`AREA', 
Width=19, Decimals=11
Field 1: Type=Double, Title=`PERIMETER', Width=19, Decimals=11
Field 2: Type=Integer, Title=`BABUY2_', Width=9, Decimals=0
Field 3: Type=Integer, Title=`BABUY2_ID', Width=9, Decimals=0
                AREA           PERIMETER   BABUY2_ BABUY2_ID
787832.00000000000  3823.87988281250    2         1
7.50226000000e+007  35785.00000000000   3         1
2671240.00000000000 7036.04980468750    4         1
1.94556992000e+008  69256.60156250000   5         1
6.40785000000e+007  40739.60156250000   6         1
54942.19921875000   908.68597412109     7         1
1.68442000000e+008  69378.29687500000   8         1
275060.00000000000  2211.82006835938    9         1
67753.50000000000   1032.68005371094    10        1
9.32392000000e+007  50166.69921875000   11        1
745418.00000000000  3506.34008789063    12        1
976459.00000000000  4958.12988281250    13        1
3933290.00000000000 7308.72021484375    14        1

Basically, the AREA field is defined as 19.11 (19 wide with 11 decimal
places).  But some of the area values are too large to fit in this so
it appears that ESRI software is just putting them in exponential format
(the -r dumps the raw contents of the fields).

Well, I, perhaps foolishly, carry the width and precision information into
PostgreSQL.  And it actually enforces the precision limits.

The solution is to use the PRECISION=NO layer creation option.  This forces
OGR to create the fields as FLOAT8 instead of NUMERIC(19,11).  I tried with
your dataset and it works fine.

There is a certain tension between OGR trying to carry declaritive
information about field definitions or layer types through to PostGIS vs.
doing stuff in the most flexible way possible.

In any event, I was able to load the layer you provided using the command:

ogr2ogr -update -nlt geometry -lco OVERWRITE=yes -lco PRECISION=no \
         PG:dbname=warmerda babuyan.shp

Good luck,

-- 
---------------------------------------+--------------------------------------
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