# from sftime object
g <- st_sfc(st_point(1:2))
time <- Sys.time()
x <- st_sftime(a = 3, g, time = time)
st_time(x)
## assign a vector with time information
# to sf object
x <- st_sf(a = 3, g)
st_time(x) <- time
x
# to sftime object
x <- st_sftime(a = 3, g, time = time)
st_time(x) <- Sys.time()
## change the time column to another already existing column
st_time(x) <- "a"
## remove time column from sftime object
st_time(x) <- NULL
## pipe-friendly
# assign time column to sf object
x <- st_sf(a = 3, g)
x <- st_set_time(x, time)
# remove time column from sftime object
st_set_time(x, NULL)
## drop time column and class
# same as x <- st_set_time(x, NULL)
st_drop_time(x)
Run the code above in your browser using DataLab