how can I read a gdb file using python

12651
4
08-12-2020 08:26 AM
Romero_Dario
New Contributor II

I have browsed the web searching for way to install the FileGDB API in order to be able to use the driver to read gdb files from python. I have downloaded the file filegdb_api_vs2012_1_4.zip and within I found the FileGDBAPI.dll which I've placed on C:\ProgramData\Anaconda3\envs\gis2\Lib\site-packages\osgeo. When I do this test below, the driver doesn't come up. COuld you please provide some assistance on this? Thanks.

from gdal import ogr

driver = ogr.GetDriverByName("FileGDB")

print(driver.GetName())

and I get this error:

AttributeError: 'NoneType' object has no attribute 'GetName'

Tags (3)
0 Kudos
4 Replies
dbabbitt
New Contributor

When you run this:

 

from osgeo import ogr

driver_name_list = [ogr.GetDriver(id).GetName() for id in range(ogr.GetDriverCount())]
for driver_name in sorted(driver_name_list):
    ds = ogr.GetDriverByName(driver_name)
    if ds is not None:
        print(driver_name)

 

What does it output?

0 Kudos
AbhayDuvvuri2
New Contributor II

FileGDB isnt part of the drivers list.

I am using 

ARCGEN
AVCBin
AVCE00
AeronavFAA
AmigoCloud
BNA
CAD
CSV
CSW
Carto
Cloudant
CouchDB
DB2ODBC
DGN
DXF
EDIGEO
EEDA
ESRI Shapefile
ESRIJSON
ElasticSearch
GFT
GML
GPKG
GPSBabel
GPSTrackMaker
GPX
GeoJSON
GeoJSONSeq
GeoRSS
Geoconcept
Geomedia
HTF
HTTP
Idrisi
JML
JP2OpenJPEG
JPEG2000
KML
LIBKML
MBTiles
MSSQLSpatial
MVT
MapInfo File
Memory
NGW
ODBC
ODS
OGR_GMT
OGR_PDS
OGR_SDTS
OGR_VRT
OSM
OpenAir
OpenFileGDB
PCIDSK
PDF
PDS4
PGDUMP
PGeo
PLSCENES
PostgreSQL
REC
S57
SEGUKOOA
SEGY
SQLite
SUA
SVG
SXF
Selafin
TIGER
TopoJSON
UK .NTF
VDV
VFK
WAsP
WFS
WFS3
Walk
XLS
XLSX
XPlane
netCDF

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

If you only need to read file geodatabases, I recommend using https://gdal.org/drivers/vector/openfilegdb.html , it is built into GDAL.

0 Kudos
AbhayDuvvuri2
New Contributor II

Hi, I am trying to install FileGDB API to read/write file geodatabases using gdal. I have successfully installed FileGDB in Linux and am able to run the samples. (eg: LD_LIBRARY_PATH is set correctly)

I then installed miniconda and installed gdal using

conda install -c conda-forge gdal

I am unable to find driver for "FileGDB" but other drivers like "OpenFileGDB" seem to work fine. Please suggest what I might be doing wrong.

Python code:
 
from osgeo import ogr
driver = ogr.GetDriverByName("FileGDB")
print(driver.GetName())