Read layers from a file geodatabase (.gdb)
read_gdb(path, layer = NULL, quiet = TRUE, by_bbox = NULL, ...)Path to a .gdb directory (the folder whose name ends in
.gdb).
If NULL (default), every layer reported by sf::st_layers()
is read. If a character string, only that layer is read; it must exist in
the geodatabase.
Passed to sf::read_sf().
If NULL (default), every feature is read. Otherwise an
sf, sfc, bbox or named numeric vector (xmin, ymin, xmax,
ymax) whose bounding box limits the features read: only features that
intersect it are returned, filtered by GDAL at read time through the
wkt_filter argument of sf::st_read(). The bounding box is
reprojected to each layer's CRS; if it has no CRS, its coordinates are
assumed to be in the layer's CRS. If the layer has no CRS it can be
reprojected to (no .prj, or an undefined LOCAL_CS), the coordinates
are used as-is with a warning. Features with empty geometry are
dropped. Layers without a geometry column (e.g. a shapefile made of a
.dbf only, or an attribute table in a GeoPackage) cannot be filtered:
they are read in full with a warning. When set, nrows_aka_features
reports the number of features read, not the layer total. Cannot be
combined with wkt_filter in ....
Additional arguments passed to sf::read_sf().
A tibble with columns fpath (path or GDAL dsn used for the layer),
file_type (tools::file_ext()), layer_name, geometry_type, nrows_aka_features,
ncols_aka_fields, crs_name (from st_layers()$crs when available), and
data (list-column of sf::sf objects). Layers are not row-bound; differing CRS are preserved
per row.
Other geo-io:
clean_geo(),
read_geo(),
read_kmz(),
read_sf_zip()
# \donttest{
gdb <- system.file("extdata", "misc_example.gdb", package = "misc")
if (nzchar(gdb) && dir.exists(gdb)) {
read_gdb(gdb)
read_gdb(gdb, layer = "OGRGeoJSON")
}
#> # A tibble: 1 × 8
#> fpath file_type layer_name geometry_type nrows_aka_features ncols_aka_fields
#> <chr> <chr> <chr> <chr> <int> <int>
#> 1 /home/… gdb OGRGeoJSON Multi Polygon 1 1
#> # ℹ 2 more variables: crs_name <chr>, data <list>
# }