File GeoDatabase to PostgreSQL (PostGIS)

GDAL, amongst other programs includes the ogr2ogr. The ogr2ogr program can be used to convert simple features data between file formats performing various operations during the process such as spatial or attribute selections, reducing the set of attributes, setting the output coordinate system or even reprojecting the features during translation.

In case you have Windows, you need to use the CMD to use ogr2ogr. In case of MAC or Linux you can run it via the terminal. Normally, if you have QGIS, you should already have ogr2ogr (you can assess this typing ogr2ogr in CMD terminal). Find more details on the ogr2ogr in the gdal documentation.

In this blog post we will use the ogr2ogr in order to import a File GeoDatabase (FGDB) into a PostgreSQL database.

Feature Classes Check

The first step is to check the status of the FGDB and see which Feature Classes are included. You can do this using the ogrinfo as per below:

ogrinfo geodbname.gdb

If everything installed correctly you should be able to see all the Feature Classes in the GeoDB, even if they are within and Feature Dataaset. More info on the ogrinf in the gdal documentation.

FGDB Import in the GeoDB

ogr2ogr -f "PostgreSQL" PG:"host=localhost port=5432 dbname=<<DB_NAME>> user=<<USERNAME>>" geodbname.gdb -overwrite -progress --config PG_USE_COPY YES

Since you already have checked the access to the .gdb, in case you get any error, most likely something is wrong on the GDAL installation. Check the type of error and act accordingly.

The ogr2ogr program imports all the feature classes in the geodatabase if it used as above. This includes classes within the Feature Datasets. It saves them under the public schema of the defined database.