2

I have a bunch of shapefiles that I am looping in with a bash script to load and update files but the ogr2ogr fails. I am running gdal 1.92 on ubuntu 14.04.

for file in `ls *.shp`;do ogr2ogr -progress -append -update -skipfailures -a_srs "EPSG:4326" -nlt MULTIPOLYGON -f "PostgreSQL" PG:"dbname=data_test" $file -sql "SELECT gid,name,id from ${file%.*}" -lco SCHEMA=test;done

ERROR 1: Layer test.boundary already exists, CreateLayer failed.Use the layer creation option OVERWRITE=YES to replace it.

1 Answer 1

1

May be documented in http://www.gdal.org/drv_pg.html. Perhaps ogr2ogr do not undestand to append either.

SCHEMA: Set name of schema for new table. Using the same layer name in different schemas is supported, but not in the public schema and others. Note that using the -overwrite option of ogr2ogr and -lco SCHEMA= option at the same time will not work, as the ogr2ogr utility will not understand that the existing layer must be destroyed in the specified schema. Use the -nln option of ogr2ogr instead, or better the active_schema connection string. See below example.

The active_schema example is on another page http://www.gdal.org/drv_pg_advanced.html

This example shows how to convert a set of shapefiles inside the apt200810 directory into an existing Postgres schema apt200810. In that example, we could have use the schemas= option instead. (Starting with GDAL 1.7.0)

ogr2ogr -f PostgreSQL "PG:dbname=warmerda active_schema=apt200810" apt200810

1
  • redefining the postgis connection for a different schema did the trick. wonder why it doesn't work Sep 11, 2014 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.