[Gdal-dev] ogr2ogr shapefile to postgis error

Frank Warmerdam warmerdam at pobox.com
Wed Sep 29 22:56:30 EDT 2004

Michael Mallete wrote:
> good day sir! thank you very much for your kind reply. :)
> yes it's a new table being created by ogr2ogr. how do i set the
> CPL_DEBUG environment variable?
> anyways, i am using the OpenEV_FW kit in a Win2k platform. i am using
> ogr2ogr to convert and insert shapefiles to postgis to an external
> server running on a win2k server platfrom. i've had success converting
> and inserting my other shapefiles. i only encounter this problem from
> time to time. i'm wondering what's so unique with the data which
> failed with the data which were successfully converted/inserted.
> anyways, thanx again sir! hoping my problem is solvable. 


OK, on review of the OGR PostGIS code and your error message, I am now
guessing that your shapefiles contains polygons and OGR reports it's
geometry type as Polygon.  If so, ogr2ogr will try to create a PostGIS
table where the geometry column is constrained to be of type polygon.

However, polygon shapefiles can actually have some "multi-island"
polygons.  Recently OGR was improved to treat these as Multipolygons
as they ought to be according to the OpenGIS Simple Features geometry
model.  The downside is that you can't put MultiPolygons into a Polygon
geometry column in PostGIS.

If everything was being done manually, the trick would be to set the
geometry type of the column to "GEOMETRY" in the AddGeometryColumn()

I was just going to say that ogr2ogr provides no means to do this.
But on review of the ogr2ogr commandline options I see it does!

You should be able to add "-nlt geometry" to tell ogr2ogr to create the
new layer with unconstrained geometry.  Let me know if this works.

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