Skip to contents

Convert class between sf/stars-terra

Usage

dep_switch(input)

Arguments

input

Spat* in terra or sf object.

Value

Data converted to the other package class (if sf, terra; if terra, sf)

See also

Other Helper functions: datamod(), dep_check(), get_clip_ext(), par_def_q(), reproject_std(), reproject_to_raster()

Author

Insang Song

Examples

if (FALSE) { # \dontrun{
library(sf)
library(stars)
library(terra)
options(sf_use_s2 = FALSE)

## generate a random raster
ras_rand <- terra::rast(nrow = 30, ncol = 30)
terra::values(ras_rand) <- runif(900)
stars_rand <- dep_switch(ras_rand)
stars_rand
inherits(sf_rand, "stars") # TRUE
# should return stars object

vec_rand <- terra::spatSample(ras_rand, size = 10L, as.points = TRUE)
sf_rand <- dep_switch(vec_rand)
inherits(sf_rand, "sf") # TRUE
sf_rand
# should return sf object
} # }