[gdal-dev] Mapinfo --> postgis db using ogr2ogr, failing to overwrite

Even Rouault even.rouault at mines-paris.org
Thu Mar 14 05:33:55 PDT 2013

Selon Pete <petern at pembrokeshirecoast.org.uk>:

> Hi, Sorry to revive this post but I'm a non GIS type and have a similar
> issue.
> I'm trying to upload a mapinfo layer using WinSCP and Ogr2Ogr to work it's
> magic to put it into the GeoStore, this via GeoServer ensures our Openlayers
> map is up-to-date.
> The trouble is that I get the exact same error IF the existing table being
> overwritten has views based on it, otherwise the overwrite works fine.
> The views go to make up the layers on the map that can be turned on/off.  I
> really don't want to end up with a table for each of these !
> Is this possible ?   is there a better way of doing it ?
> *The command we’re using *
> call ogr2ogr -f "PostgreSQL" PG:"host=localhost user=pembs dbname=pembs
> password=12345" ./WindTurbines.TAB  -nln public.windturbines -lco
> *The Error we get*
> failed with return code 1 and error message
> ERROR 1: CREATE TABLE "public"."windturbines" ( OGC_FID SERIAL, CONSTRAINT
> "windturbines_pk" PRIMARY KEY (OGC_FID) )
> ERROR:  relation "windturbines" already exists
> ERROR 1: Terminating translation prematurely after failed
> translation of layer WindTurbines (use -skipfailures to skip errors).
> Appologies again that i'm not a GIS bod so hope my lack of understanding
> doesn't confuse you!

I guess that the -lco OVERWRITE=YES that cause a "DROP TABLE windturbines" must
fail because the table is referenced by the views.
One option, provided that the structure of the existing windturbines table is
compatible with the windturbines.tab file you want to inject into it, would be
to :

1) ogrinfo PG:"host=localhost..." -sql "DELETE FROM windturbines"
2) ogr2ogr -update -append PG:"host=localhost..."  ./WindTurbines.TAB -nln

> Pete
> --
> View this message in context:
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

More information about the gdal-dev mailing list