Skip to content

Instantly share code, notes, and snippets.

@codegordi
Forked from gislars/filegdb2shp
Last active August 29, 2015 14:03
Show Gist options
  • Save codegordi/507c17cb35385fdce531 to your computer and use it in GitHub Desktop.
Save codegordi/507c17cb35385fdce531 to your computer and use it in GitHub Desktop.
1) Get the FileGDB API http://www.esri.com/apps/products/download/
2) Extract it somewhere on your system and remember the path :)
3) Do:
> mkdir build #directory where we are playing around
> cd build
> git clone https://github.com/OSGeo/gdal.git
> cd gdal
> ./configure --with-fgdb=/path/to/your/FileGDB_API
> make # this will take a while ....
# (make install) # optional, I'm just using it locally
*** Note: you will need all the dependencies, development files as well as all the compile tools _before_ configuring and compiling geo. I don't dig into this topic here, but if somebody has trouble, I might be able to help. ***
4) First test:
build/gdal/apps/ogrinfo --formats # I have to use absolute paths, since I didn't install gdal system wide
- If you are lucky you will see a output like this:
Supported Formats:
...
-> "FileGDB" (read/write)
...
5) Now you can use ogrinfo or ogr2ogr to access your FileGDB
> build/gdal/apps/ogrinfo /path/to/your/database.gdb <layername> -summary
* Convert a FileGDB to Shapefile:
> build/gdal/apps/ogr2ogr -f "ESRI Shapefile" <out_directory> /path/to/your/database.gdb
--> A directory will be created and for each layer within the filegdb a shapefile set will be created.
* You could also use a query to retrieve a subset of your filegdb. There is an example on the gdal site http://www.gdal.org/ogrinfo.html
@codegordi
Copy link
Author

This is OK, but there is an easier way to install as a homebrewed gdal plug-in

  1. Get the FileGDB API http://www.esri.com/apps/products/download/ # same as above
  2. Extract it somewhere on your system and record the path (homebrew will require its /Library/Caches/Homebrew) # same as above
  3. Do:

mv ~/Downloads/FileGDB_API_1_3-64.zip /Library/Caches/Homebrew
export GDAL_THIRD_PARTY=/Library/Caches/Homebrew
brew install gdal-filegdb
export GDAL_DRIVER_PATH=/usr/local/lib/gdalplugins
4) Check that FileGDB API is plugged in:
ogrinfo --formats
Supported Formats:
-> "FileGDB" (read/write)
5) Test it:

==> You should end up with several files output, including the .shp (ESRI shapefile(s))

@codegordi
Copy link
Author

Note: The ESRI FileGDB API only converts ESRI v. 10+ .gdb's. May want to consider using OpenFileGDB instead for vv. 9.+.
http://www.gdal.org/drv_openfilegdb.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment