R/sf_stars_functions.R

Defines functions to_sf_stars

to_sf_stars <- function(x) {
    if (inherits(x, c("sf", "sfc", "stars"))) {
        x
    } else if (inherits(x, c("Raster", "SpatialGrid", "SpatialPixels"))) {
        stars::st_as_stars(x)
    } else if (inherits(x, "sp")) {
        as(x, "sf")
    } else {
        stop("unknown spatial object", call. = FALSE)
    }
}

Try the tmaptools package in your browser

Any scripts or data that you put into this service are public.

tmaptools documentation built on Jan. 20, 2021, 1:07 a.m.