24

I ran into a problem when loading a ESRI Geodatabase format .gdb into PostGIS. I have data 2.5GB GDB file. I followed some tutorials on the internet, but it seems that doesn't work out.

  1. I created a database "SampleNY"
  2. I executed this from the console:

    ogr2ogr -f "PostgreSQL" PG:"dbname=SampleNY user=postgres" NYPluto/Pluto.gdb

But nothing happens, I didn't got neither an error nor a successful operation. Did I miss any steps?

Fezter
  • 21,867
  • 11
  • 68
  • 123
user3001937
  • 623
  • 3
  • 8
  • 15

2 Answers2

27

Try adding appropriate host and port arguments.
And BTW, when I import a large GDB file, I also add these flags:

-overwrite (erases any mess you may have already inserted) and

-progress (displays a dot or number for every 10,000 or 10% records added):

--config PG_USE_COPY YES (greatly improves speed)

So the command (which should be a one-liner but i formatted here for clarity) becomes

ogr2ogr 
    -f "PostgreSQL" 
    PG:"host=localhost port=5432 dbname=SampleNY user=postgres" 
    NYPluto/Pluto.gdb 
    -overwrite -progress --config PG_USE_COPY YES

Use a URL in place of "localhost" if needed.

Martin F
  • 8,948
  • 36
  • 58
12

If there are multiple features in the gdb and you want to specify the Postgres schema and table names then follow:

#First get the featurenames from the gdb:
ogrinfo geodbname.gdb

#then import a feature into a table:
ogr2ogr -f "PostgreSQL" PG:"host=hostname port=5432 dbname=dbname user=postgres"
geodbname.gdb -nlt PROMOTE_TO_MULTI -nln schemaname.tablename featurename -overwrite
anneb
  • 1,371
  • 11
  • 11
  • most helpful answer imo. You might add that if you know the geometry type, you can set that for -nlt instead of PROMOTE_TO_MULTI (i.e. MULTILINESTRINGZM, POINT, etc.). Also, I have noticed that esri gdbs often contain multicurve geometries, which will fail when using PROMOTE_TO_MULTI with geometry type (MultiCurve) does not match column type (MultiLineString). If you set -nlt MULTILINESTRING, it works (also works with M and ZM) – jbalk Jul 29 '22 at 19:24