4

I'm trying to get python 2.7 to work with GDAL/OGR and an ESRI file geodatabase. There have been a few similar questions asked but the answers don't fully resolve my situation.

I have installed the 64-bit GDAL Core files from http://www.gisinternals.com/sdk/ I have also installed the Python Bindings and the File GDB.

The background to the problem is that when I run ogrinfo --formats from the command line it returns: "FileGDB" (read/write), when I run ogr from the command line I can see the layers in the Geodatabase BUT when I try to use the following code in Python in returns "None"

driver = gdal.GetDriverByName('FileGDB')
ds = driver.Open(r"my file.gdb",0)
print driver

Ogr definitely works in python because the following code returns the correct response:

driver = ogr.GetDriverByName("ESRI Shapefile")
ds = driver.Open(r"My Shapefile.shp",0)
print ds

driver = gdal.GetDriverByName('GTiff')
ds = driver.Open(r"My GeoTiff.shp",0)
print driver

Does anybody have any pointers to resolve this.

Thanks

  • 3
    I sense a slight confusion between OGR and GDAL. Try instead: ogr.GetDriverByName('FileGDB') – Mike T Jul 1 '13 at 4:01
  • I've tried that and still no joy. It still returns nothing instead of the SWIG object that it should. – user19466 Jul 2 '13 at 4:40
3

I found the solution to this was to add GDAL_DRIVER_PATH = C:\Program Files\GDAL\gdalplugins in the Environment Variables.

This was in addition to Mike Toews comment about the correct usage being ogr.GetDriverByName('FileGDB')

  • 1
    Difficult find! This can also be set in Python with os.environ['GDAL_DRIVER_PATH'] = r'C:\...', either before importing ogr, or by calling ogr.RegisterAll() after setting the variable. – Mike T Jul 4 '13 at 4:41
  • I was using the pre-built Python GDAL Windows binaries, which don't require GDAL to be installed. In addition to setting GDAL_DRIVER_PATH to point at the location inside the site-packages directory, I had to ensure FileGDB.dll was on PATH. (I had to download FileGDB.dll from ESRI separately.) – jpmc26 Jan 7 '14 at 22:08
0

If you are interested in using the File Geodatabase API with Python, read my post: http://libjoe.blogspot.com/2014/02/python-wrapper-for-esri-file.html

Also, see the project page: https://code.google.com/p/file-geodatabase-api-python-wrapper/

Enjoy! Joseph Armbruster

  • This question is specifically about GDAL bindings, so your self-promotion makes little sense here (as opposed to the other question). – lynxlynxlynx Feb 2 '14 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.