0

I'm trying to load a relatively big Geopackage into my database with ogr2ogr and Windows Subsystem for Linux:

ogr2ogr -f PostgreSQL "PG:user=postgres password=#### dbname=db host=localhost port=5432" de_grid_etrs89_utrm32_100m.gpkg -lco LAUNDER=NO

This syntax works for other gpkg's but not for this one. Error Message:

ERROR 1: CREATE TABLE "public"."de_grid_utm32_100m" ( "rowid" SERIAL, PRIMARY KEY ("rowid"), "featuretype_name" VARCHAR(200), "dataset_name" VARCHAR(200), "OBJECTID" INTEGER, "id" VARCHAR(254), "x_sw" FLOAT8, "y_sw" FLOAT8, "x_mp" FLOAT8, "y_mp" FLOAT8, "f_staat" FLOAT8, "f_land" FLOAT8, "f_wasser" FLOAT8, "p_staat" FLOAT8, "p_land" FLOAT8, "p_wasser" FLOAT8, "Shape_Length" FLOAT8, "Shape_Area" FLOAT8, "ags" VARCHAR(50), "geom" geometry(GEOMETRYZM,1) )
FEHLER: aktuelle Transaktion wurde abgebrochen, Befehle werden bis zum Ende der Transaktion ignoriert
ERROR 1: Unable to write feature 1 from layer de_grid_utm32_100m.
ERROR 1: Terminating translation prematurely after failed
translation of layer de_grid_utm32_100m (use -skipfailures to skip errors)

My guess is that it's some encoding issue with the german language. Does anyone have a clue on what I should try next?

Gdal version: GDAL 2.4.2 PostgreSQL version: 12

Edit: Ogrinfo screenshot enter image description here

3
  • 2
    Test manually with psql if you can create the table by copyig the whole create table part CREATE TABLE "public"."de_grid_utm32_100m" ( "rowid" SERIAL, PRIMARY KEY ("rowid"), "featuretype_name" VARCHAR(200),.... If you can then have a look at the first feature with ogrinfo -sql "select * from de_grid_utm32_100m limit 1". On Windows you may need to escape all underscores with backslash \_.
    – user30184
    Commented Mar 27, 2020 at 9:10
  • 1
    That CREATE TABLE works for me. Unfortunately it is very hard to say why it does not work for you. I do not see anything special it the table definitions.
    – user30184
    Commented Mar 27, 2020 at 9:39
  • Sorry, It works for me now as well. Added a Snapshot in the Edit from ogrinfo.
    – Phil
    Commented Mar 27, 2020 at 9:45

1 Answer 1

1

Solved it by overwriting my existing table with:

ogr2ogr -overwrite -f PostgreSQL "PG:user=postgres password=##### dbname=geodb host=localhost port=5432 active_schema=public" de_grid_etrs89_utrm32_100m.gpkg  -lco LAUNDER=no
2
  • Good that is solved your problem. However, generally -overwrite in not needed and GDAL driver seems to add features into existing table when running the same ogr2ogr command again. One could actually imagine by the ogr2ogr documentation that options -update and -append should be used for achieving this. It seems that your database was left in an odd situation by a not committed transaction.
    – user30184
    Commented Mar 27, 2020 at 10:49
  • I will try that as well later. Thank you!
    – Phil
    Commented Mar 27, 2020 at 10:52

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.