1

I have a .gdb directory with 40+ layers inside. When I load it into QGIS (3.36, also tested under 3.34) not all layers have features. Some are just empty (the attribute tables do not even have columns, I just see a blank space).

I have tried adding it by simply dragging and dropping it in QGIS. I have used the add vector layer dialogue and chose OpenFileGDB as well as ESRI FileGDB as the Type.

Screenshot of the filebrowser in QGIS. WSG should have 1000+ features

I also tried loading them via a short Python script as well as an R script.

Both throw errors at me

Python:

ERROR 1: Error occurred in C:\b\abs_8d_zthwwfr\croot\gdal-split_1704913289492\work\ogr\ogrsf_frmts\openfilegdb\filegdbtable.cpp at line 1017

R:

Reading layer `WSG' from data source 
          `C:\path\to\file\DC40_OWL_RWK.gdb' 
          using driver `OpenFileGDB'
        Simple feature collection with 0 features and 0 fields
        Bounding box:  xmin: NA ymin: NA xmax: NA ymax: NA
        Projected CRS: ETRS89 / UTM zone 32N
        Warnmeldung:
        In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
          GDAL Error 1: Error occurred in ../../../../gdal-3.8.4/ogr/ogrsf_frmts/openfilegdb/filegdbtable.cpp at
        line 1007

A colleague who is also using QGIS (3.34) was able to normally load all layers.

I found another post hinting, that it might be a compressed .gdb causing the problem, but it seems not to be the case.

Is there something I am missing? A certain driver or so?

What would be a solution to this so that I can load it all incorrectly?

I am using QGIS 3.36 on Windows 11.

1
  • 3
    QGIS reads file geodatabases using either the OpenFileGDB or ESRI GDB driver. So if the one you used is causing problems you might try the other. In QGIS try the add vector layer, directory source and then see if you have both drivers. If you are missing one and used the OsGeo4W installer you can go back and add the missing driver.
    – John
    Commented Jun 10 at 17:34

1 Answer 1

1

I have found a solution. It seems to be the case that it was indeed a compressed gdb. I managed to read it in via the Python Console in QGIS using the FileGDB driver:

from osgeo import ogr

driver = ogr.GetDriverByName("FileGDB")

⚠️ Note, FileGDB is different from OpenFileGDB which is only reading in some layers.

from osgeo import ogr

gdb_file = 'C:/path/to/file/name_of_file.gdb'
 
for i in range(0, 43):
    path_gdb_network = 'C:/path/to/file/name_of_file.gdb'
    driver = ogr.GetDriverByName("FileGDB")
    source = driver.Open(path_gdb_network)
    lyr = source.GetLayer(i)
    print(lyr.GetName())
    print(lyr.GetFeatureCount())

As I did not know the correct Python code to continue from here, I took another solution, converting the .gdb using the command line tool ogr2ogr from within the OSGeo4W Shell:

ogr2ogr  -f GPKG "C:/path/to/file/name_of_file.gpkg" "C:/path/to/file/name_of_file.gdb" --config OGR_SKIP OpenFileGDB

It is important to set the last argument --config OGR_SKIP OpenFileGDB as otherwise the OpenFileGDB driver would be used which does not read all layers correctly. This creates a GeoPackages with all the layers that can be read by QGIS. Sadly 'substructures' within the original .gdb are not preserved.

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.