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?

10
  • Are you limited to using ogr2ogr? Or are you open to other solutions? FME should be able to do this easily.
    – Fezter
    Jan 15, 2014 at 4:07
  • I am open to any solution that can solve this problem ? Can you provide more details about how to do that ? Jan 15, 2014 at 4:08
  • Try downloading FME. Create a new workbench and add a Geodatabase Reader and a PostGIS writer.
    – Fezter
    Jan 15, 2014 at 4:09
  • 1
    It is a commercial solution. You didn't specify you were only looking for free solutions. I think FME has a free trial period.
    – Fezter
    Jan 15, 2014 at 4:22
  • 1
    I found in other answers Spatial Data Manager. mapet.altervista.org This is a free windows tool to load shapefile and file geodatabase in Postgis and other spatial db.
    – lele3p
    Jan 15, 2014 at 5:13

2 Answers 2

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.

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
1
  • 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, 2022 at 19:24

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.