[Blog] Working with File Geodatabases (.gdb) using QGIS and GDAL
Despite the widely held misconception that file geodatabases (.gdb) can only be read and edited using tools within Esri's ArcGIS platform, recent versions of GDAL (and, therefore, GDAL-utilizing applications like QGIS) are capable of efficiently reading and extracting information from file geodatabases. The file geodatabase format has emerged as a very common format for storing and exchanging spatial data, particularly considering that it allows for the storage of multiple data layers, and that it allows for the storage of data layers that exceed the limits of other specifications. Users of ArcGIS regularly use file geodatabases when attribute tables exceed the storage capacity of a shapefile attribute table (an individual DBF file is limited to ~2GB in size).
GDAL users who work with file geodatabases should know that GDAL now includes a very robust open source, read-only driver for the file geodatabase format: OpenFileGDB. The driver's specifications indicate that this driver is capable of efficiently reading the contents of databases with large numbers of fields, without depending in any way upon proprietary software.
An additional option for interacting with file geodatabases using GDAL is the FileGDB driver. FileGDB depends upon Esri's File Geodatabase SDK, but it provides both read and write access to file geodatabases. However, internal testing at Geospatial @ UCLA has indicated that for read-only file geodatabase operations, FileGDB driver can be many orders of magnitude slower than the OpenFileGDB driver.
Therefore, users needing to regularly edit file geodatabases should install and use the FileGDB driver, while users needing only to convert file geodatabase contents to other formats should use the OpenFileGDB driver.
QGIS users can read file geodatabases by dragging the geodatabases, ending in the extension .gdb, directly into the Layers pane. The geodatabase may appear as a folder and may not be selectable using the Add Vector Layer tool in QGIS. The contents of the file geodatabase will appear in the Layers pane, and each layer can be exported to any other format with write support in GDAL, including the shapefile format.
For large geodatabases whose contents exceed the limits of the shapefile specification, we recommend using GDAL's ogr2ogr command line interface to copy the contents of a file geodatabase directly to a PostGIS database. Use the following command, replacing the text between square braces with values appropriate to your configuration (square braces should not be included in your command):
ogr2ogr -progress -overwrite -skipfailures -f "PostgreSQL" PG:"host=localhost user=[postgres] dbname=[dbname] password=[password]" "[pathtofilegdb].gdb" "[tablename]"