spatial_read: Wrapper functions for reading spatial objects.

spatial_readR Documentation

Wrapper functions for reading spatial objects.

Description

Read either simple features (package sf) from disk using appropriate functionality (“engine”) of respective packages is used.

Usage

spatial_read(dsn, engine = c("native", "sf"))

Arguments

dsn

Character. File name of spatial object (vector GIS).

engine

Character. Functionality of which package is used for reading data. If value is "sf", then package sf is used and simple features are returned. If value is "geojsonsf", GDAL driver is GeoJSON and package geojsonsf can be loaded, then package geojsonsf is used and simple features are returned. If value is "sp" and package sp can be loaded, then Spatial abstracts (package sp) are returned. If value is "native" then engine selection depends on has suggested package sf been installed and is there possibility to use geosonjf for GeoJSON driver.

Details

Currently, list of arguments of this funtion is simplified and can be expanded.

Value

Depending of used engine, either simple features (package sf) or Spatial abstracts (sp).

Note

For GeoJSON files in the case engine="geojsonsf" reading is faster and the order of fields can be rearranged.

Author(s)

Nikita Platonov platonov@sevin.ru

See Also

read_sf

spatial_write

Examples

session_grid(NULL)
n <- 1e2
x <- runif(n,min=25,max=65)
y <- runif(n,min=55,max=65)
z <- runif(n,min=1,max=10)
da <- data.frame(x=x,y=y,z=z)
if (requireNamespace("sf",quietly=TRUE)) {
   obj1 <- sf::st_as_sf(da,coords=c("x","y"),crs=4326)
   print(series(obj1))
   fname1 <- file.path(tempdir(),"res1.shp")
   print(fname1)
   spatial_write(obj1,fname1)
   res1 <- spatial_read(fname1,engine="sf")
   print(series(res1))
}
print(spatial_dir(tempdir()))

nplatonov/ursa documentation built on May 8, 2024, 6:02 p.m.