2

I am reading in GML data to a specified PostGIS schema. This is part of an automated job so and the db table might include views so I don't want to drop the table each time the script is run.

EDIT: It append and truncate works if I dont specify the schema. But in my workflow I have to use a specified schema.

Trying to do this:

Typical use case: “ogr2ogr -append PG:dbname=foo abc.shp –config OGR_TRUNCATE YES

ogr2ogr -append -f "PostgreSQL" PG:"host=localhost user=postgres dbname=geospatial password=postgres" \
    -lco SCHEMA=test \
    -lco GEOMETRY_NAME=geom \
    "C:\Users\my_GML.gml" \
    –config OGR_TRUNCATE YES

This result in ERROR 1: Couldn't fetch requested layer '–-config'! ????

EDIT: Double dash is the correct way –-config OGR_TRUNCATE YES

In addition if I run a standard append version

ogr2ogr -append -f "PostgreSQL" PG:"host=localhost user=postgres dbname=geospatial password=postgres" \
    -lco SCHEMA=test \
    -lco GEOMETRY_NAME=geom \
    "C:\Users\myGML.gml"

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

What am I doing wrong?

6
  • try –config OGR_TRUNCATE=YES
    – Ian Turton
    Jul 3, 2019 at 10:11
  • Did not work. I am running it from within jupyter notebook. Nad now i get Unknown option name '-config' .... Will jump out and try it in the regular command window as jupyter seem to cache som unexpected things.
    – geogrow
    Jul 3, 2019 at 10:20
  • Using --config OGR_TRUNCATE YES as described in the doc for confg params: trac.osgeo.org/gdal/wiki/ConfigOptions. Seem to be accepted. Still get the ERROR 1: Layer test.mylayer already exists, CreateLayer failed. Ignoring the append method
    – geogrow
    Jul 3, 2019 at 10:25
  • Turn out its because I use the -lco schema=<...> that it wont work. Need to find another way to solve it if I cannot specifiy my schema
    – geogrow
    Jul 3, 2019 at 10:43
  • 2
    use schemas=test in the PG params instead
    – Ian Turton
    Jul 3, 2019 at 11:03

1 Answer 1

1

So if you use -lco schema=... it prevents you using --config OGR_TRUNCATE=YES the answer is to use schemas=test in the PG: parameters along with hostname etc.

Your Answer

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

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