5

I have upgraded to GDAL 2.1 on Windows, binaries from: http://www.gisinternals.com/query.html?content=filelist&file=release-1800-gdal-2-1-2-mapserver-7-0-2.zip

I am able to use the command line:

> ogrinfo -al "C:/path/to/my/folder.gdb"

and it works fine, giving me details of the contents.

However, from my C code:

 GDALDatasetH dataset = GDALOpen( "C:/path/to/my/folder.gdb", GA_ReadOnly );

I get back NULL, and the console says:

  ERROR 4: `C:/path/to/my/folder.gdb' not recognized as a supported file format.

Yet I am still able to successfully open other files with GDALOpen(), such as .tiff, .sid, and others (all rasters, this is the first time I'm trying to open a vector file). Further, when I use GDALGetDriverCount() and GDALGetDriver(), and print the short and long name of each driver, I get a list of 200 drivers, including:

159 ESRI Personal GeoDatabase -- PGeo
160 MySQL -- MySQL
161 ESRI FileGDB -- OpenFileGDB

At one point I was including ogr_FileGDB.dll in my plugins directory, and that was giving a .dll load error on GDALAllRegister() because I don't have the Esri GDB SDK .dlls. But I thought maybe just having ogr_FileGDB.dll in the plugins directory was confusing GDAL and that's why the OpenFileGDB driver wasn't working. But even after removing ogr_FileGDB.dll from the plugins directory, I still get NULL when opening the .gdb.

Any ideas for how I can figure out what's going on?

3
  • 1
    The "OpenFileGDB" driver doesn't have anything to do with Esri's file geodatabase DLL.
    – Vince
    Commented Nov 21, 2016 at 1:02
  • Well, if I had the Ersi SDK installed and both the FileGDB driver and the OpenFileGDB driver got registered, and then I opened a .gdb folder, presumably one of those drivers would chosen to open the dataset, in preference to the other, so in that way they do have something to do with each other, right?
    – M Katz
    Commented Nov 22, 2016 at 1:23
  • No, GDAL would have something to do with each of them. Directionality is important. A->B and A->C does not imply B->C or C->B
    – Vince
    Commented Nov 22, 2016 at 1:44

1 Answer 1

6

TL;DR Use GDALOpenEx

GDAL can only read vector data from File GDBs* and the GDALOpen method is for raster data. This is why you get ERROR 4: 'C:/path/to/my/folder.gdb' not recognized as a supported file format..

* Raster support was added to the OpenFileGDB driver in GDAL version 3.7

In GDAL 1.X you would use OGROpen to open vector data.

In GDAL 2.X you can still use OGROpen to open vector data and GDALOpen to open raster data but note that both methods are deprecated in favour of the unified method GDALOpenEx.

2
  • More info trac.osgeo.org/gdal/wiki/rfc46_gdal_ogr_unification
    – user2856
    Commented Nov 21, 2016 at 20:42
  • To clarify, I had a comment that they should rename the functions to make it more clear, but deleted it because I realized that made no sense since it would break existing code, as Luke replied.
    – M Katz
    Commented Nov 21, 2016 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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