I use the following ogr2ogr
command to import my open file geodatabase into PostgreSQL.
# Note, I use the -append because I am adding to preexisting tables with the same structure
ogr2ogr -append -f "PostgreSQL" PG:"dbname=database host=localhost user=username password=password" my.gdb
This works just fine, but it always specifies the geometry field as wkb_geometry
, and I'd like it to be geom
as is the usual convention. I thought this might be controlled by the -geomfield
option, but it seems that this is the not the correct flag (the documentation is too vague for me to be sure though).
If it was just one geodatabase, I could simply loop through and rename all the columns to geom
, but since I will be appending multiple databases together that won't work.
1 Answer 1
In the help in ogr2ogr --long-usage
, there is layer creation option:
-lco NAME=VALUE: Layer creation option (format specific)
You can use the driver specific option GEOMETRY_NAME=geom
to
Set name of geometry column in new table
as follows:
ogr2ogr -lco GEOMETRY_NAME=geom -append -f "PostgreSQL" PG:"dbname=database host=localhost user=username password=password" my.gdb
See related question How to let ogr/gdal CreateLayer() create a `geom` field instead of `wkb_geometry`?.
-
This works, however, I am having trouble adding the laundered option to
-lco
. Is there some trick to passing multiple parameters to-lco
?ogr2ogr -lco GEOMETRY_NAME=geom LAUNDER=NO -f "PostgreSQL" PG:"dbname=database schemas=schema" my.gdb
Andy– Andy2017年09月05日 16:43:08 +00:00Commented Sep 5, 2017 at 16:43 -
2Got it, turns out you need to specify
-lco
before each individual option.Andy– Andy2017年09月05日 16:55:47 +00:00Commented Sep 5, 2017 at 16:55
-append
then add the others. So the geom field in the tables iswkb_geometry
by default.