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?
Answer
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.
.
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
.
No comments:
Post a Comment