# ESRI File Geodatabase (OpenFileGDB)

(Available in GDAL >= 1.11)

The OpenFileGDB driver provides read access to File Geodatabases (.gdb directories) created by ArcGIS 9 and above.

It can also read directly zipped .gdb directories (.gdb.zip)

A specific .gdbtable file (including "system" tables) can also be opened directly.

## Spatial filtering

The driver cannot use the .spx files (when they are present) for spatial filtering. However, it will use the minimum bounding rectangle included at the beginning of the geometry blobs to speed up spatial filtering. By default, it will also build on the fly a in-memory spatial index during the first sequential read of a layer. Following spatial filtering operations on that layer will then benefit from that spatial index. The building of this in-memory spatial index can be disabled by setting the OPENFILEGDB_IN_MEMORY_SPI configuration option to NO.

## SQL support

SQL statements are run through the OGR SQL engine. When attribute indexes (.atx files) exist, the driver will use them to speed up WHERE clauses or SetAttributeFilter() calls.

### Special SQL requests

"GetLayerDefinition a_layer_name" and "GetLayerMetadata a_layer_name" can be used as special SQL requests to get respectively the definition and metadata of a FileGDB table as XML content (only available in Geodatabases created with ArcGIS 10 or above)

## Comparison with the FileGDB driver

(Comparison done with a FileGDB driver using FileGDB API SDK 1.3)

Advantages of the OpenFileGDB driver:

- Can read ArcGIS 9.X Geodatabases, and not only 10 or above.
- Can open layers with any spatial reference system.
- Thread-safe (i.e. datasources can be processed in parallel).
- Uses the VSI Virtual File API, enabling the user to read a Geodatabase in a ZIP file or stored on a HTTP server.
- Faster on databases with a big number of fields.
- Does not depend on a third-party library.
- Robust against corrupted Geodatabase files.

Drawbacks of the OpenFileGDB driver:

- Read-only.
- Cannot use spatial indexes.
- Cannot read data from compressed feature classes (SDC, Smart Data Compression). Nor can can FileGDB driver because the ESRI FileGDB SDK lacks also this feature.

## Examples

- Read layer from FileGDB and load into PostGIS:

  `ogr2ogr -overwrite -f "PostgreSQL" PG:"host=myhost user=myuser dbname=mydb password=mypass" "C:\somefolder\BigFileGDB.gdb" "MyFeatureClass"`

- Get detailed info for FileGDB:

  `ogrinfo -al "C:\somefolder\MyGDB.gdb"`

- Get detailed info for a zipped FileGDB:

  `ogrinfo -al "C:\somefolder\MyGDB.gdb.zip"`

## Links

- FileGDB driver, relying on the FileGDB API SDK
- Reverse-engineered specification of the FileGDB format