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)

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

# \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>
# }