R/st_cast.R

Defines functions st_cast.sftime

Documented in st_cast.sftime

#' Cast geometry to another type: either simplify, or cast explicitly
#' 
#' @name st_cast
#' @inheritParams sf::st_cast
#' @param x An object of class \code{sftime}.
#' @return \code{x} with changed geometry type.
#' @examples
#' # cast from POINT to LINESTRING
#' g <- st_sfc(st_point(1:2), st_point(c(2, 4)))
#' time <- Sys.time()
#' x <- 
#'   st_sftime(a = 3:4, g, time = time) %>%
#'   dplyr::group_by(time) %>%
#'   dplyr::summarize(do_union = TRUE) %>%
#'   st_cast(to = "LINESTRING")
#' @export
st_cast.sftime <- function(x, to, ..., warn = TRUE, do_split = TRUE) {
  reclass_sftime(NextMethod(), attr(x, "time_column"))
}

Try the sftime package in your browser

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

sftime documentation built on Sept. 12, 2024, 6:18 a.m.