read_geo: Read a geospatial file or dataset (auto-detect by extension)

View source: R/read_geo.R

read_geoR Documentation

Read a geospatial file or dataset (auto-detect by extension)

Description

Chooses the reader from tools::file_ext(path) (case-insensitive):

  • .zipread_sf_zip()

  • .kmzread_kmz()

  • .kml — internal KML reader (same tibble layout; fpath is the .kml file)

  • .gdbread_gdb()

  • anything else GDAL/sf can open on path — one row per layer from sf::st_layers() (e.g. .shp, .gpkg, .geojson)

Usage

read_geo(path, layer = NULL, quiet = TRUE, ...)

Arguments

path

Path to a spatial file or a .gdb directory.

layer

Passed to multi-layer GDAL readers. Ignored for .zip and .kmz.

quiet

Passed to sf::read_sf().

...

Additional arguments passed to sf::read_sf().

Value

A tibble as described in read_gdb().

Examples


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"))
if (file.exists(f("misc_example.kml"))) read_geo(f("misc_example.kml"))
if (file.exists(f("misc_example.gpkg"))) read_geo(f("misc_example.gpkg"))
if (file.exists(f("misc_example.geojson"))) read_geo(f("misc_example.geojson"))
if (file.exists(f("misc_example.shp"))) read_geo(f("misc_example.shp"))
if (dir.exists(f("misc_example.gdb"))) read_geo(f("misc_example.gdb"), layer = "OGRGeoJSON")


misc documentation built on April 8, 2026, 9:10 a.m.