I want to open a GDB (A directory that ends with ".gdb") in R. I am assuming that some sublayers or the whole GDB is compressed, though I do not know how to confirm this. I have tried st_read() of the sf Package, but some layers are read without any features, and I get an error message:
> st_layers("C:/path/to/name.gdb")
Driver: OpenFileGDB
Available layers:
layer_name geometry_type features fields crs_name
1 WSG Multi Polygon 0 0 ETRS89 / UTM zone 32N
2 HQSG Multi Polygon 0 0 ETRS89 / UTM zone 32N
3 Boden_natur_kultur Multi Polygon 2220 16 ETRS89 / UTM zone 32N
4 BR Multi Polygon 212 19 ETRS89 / UTM zone 32N
5 WEA Point 881 17 ETRS89 / UTM zone 32N
6 Fliessgewaesser 3D Measured Multi Line String 236407 18 ETRS89 / UTM zone 32N
7 Standgewaesser 3D Measured Multi Polygon 15905 17 ETRS89 / UTM zone 32N
8 Grundwasserflurabstand Multi Polygon 26604 15 ETRS89 / UTM zone 32N
9 Georisiken Multi Polygon 241 14 ETRS89 / UTM zone 32N
10 nat_Waldentwicklung 3D Measured Multi Polygon 7996 18 ETRS89 / UTM zone 32N
11 Kulturlandschaften Multi Polygon 78 17 ETRS89 / UTM zone 32N
12 Boden_grundwasserbeeinflusst Multi Polygon 31522 17 ETRS89 / UTM zone 32N
13 Boden_stauwasserbeeinflusst Multi Polygon 13837 17 ETRS89 / UTM zone 32N
14 Biogasanlage Point 150 16 ETRS89 / UTM zone 32N
> read_sf("C:/path/to/name.gdb",
+ "WSG")
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
# A tibble: 0 × 1
# ℹ 1 variable: SHAPE <GEOMETRY [m]>
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
I managed to convert the GDB into a GeoPackage using the following ogr command line command in the OSGeoW Shell:
ogr2ogr -f GPKG "C:/path/to/file/name_of_file.gpkg" "C:/path/to/file/name_of_file.gdb" --config OGR_SKIP OpenFileGDB
The resulting GeoPackage has a Layer WSG with the correct number of features.
Without the last argument --config OGR_SKIP OpenFileGDB it produces the empty layers again. I am assuming it forces the use of the ESRI Driver that I received by installing QGIS via the OSGeo4W installer.
Nonetheless, is there an option to read in such GDBs into R without the use of ogr2ogr or other outside R tools? A solution where I call this from within R would be much appreciated, too.
optionsargument inread_sf()to pass--config OGR_SKIP OpenFileGDBto GDAL?