Chooses the reader from tools::file_ext(path) (case-insensitive):
.zip — read_sf_zip()
.kmz — read_kmz()
.kml — internal KML reader (same tibble layout; fpath is the .kml file)
.gdb — read_gdb()
anything else GDAL/sf can open on path — one row per layer from
sf::st_layers() (e.g. .shp, .gpkg, .geojson)
read_geo(path, layer = NULL, quiet = TRUE, ...)Path to a spatial file or a .gdb directory.
Passed to multi-layer GDAL readers. Ignored for .zip and .kmz.
Passed to sf::read_sf().
Additional arguments passed to sf::read_sf().
A tibble as described in read_gdb().
# \donttest{
d <- system.file("extdata", package = "misc")
f <- function(...) file.path(d, ...)
if (file.exists(f("misc_example.zip"))) read_geo(f("misc_example.zip"))
if (file.exists(f("misc_example.kmz"))) read_geo(f("misc_example.kmz"))
#> # 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/… kmz doc "" 1 12
#> # ℹ 2 more variables: crs_name <chr>, data <list>
if (file.exists(f("misc_example.kml"))) read_geo(f("misc_example.kml"))
#> # 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/… kml misc_exam… "" 1 12
#> # ℹ 2 more variables: crs_name <chr>, data <list>
if (file.exists(f("misc_example.gpkg"))) read_geo(f("misc_example.gpkg"))
#> # 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/… gpkg misc_exam… Point 1 1
#> # ℹ 2 more variables: crs_name <chr>, data <list>
if (file.exists(f("misc_example.geojson"))) read_geo(f("misc_example.geojson"))
#> # 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/… geojson misc_exam… Point 1 1
#> # ℹ 2 more variables: crs_name <chr>, data <list>
if (file.exists(f("misc_example.shp"))) read_geo(f("misc_example.shp"))
#> # 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/… shp misc_exam… Point 1 1
#> # ℹ 2 more variables: crs_name <chr>, data <list>
if (dir.exists(f("misc_example.gdb"))) read_geo(f("misc_example.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>
# }