time | R Documentation |
Get or set the time of the layers of a SpatRaster. Time can be stored as POSIXlt
(date and time, with a resolution of seconds, and a time zone), Date
, "months", "years", or "yearmonths".
timeInfo
and has.time
are helper functions to understand what a time data a SpatRaster has.
## S4 method for signature 'SpatRaster'
has.time(x)
## S4 method for signature 'SpatRaster'
time(x, format="")
## S4 replacement method for signature 'SpatRaster'
time(x, tstep="")<-value
## S4 method for signature 'SpatRaster'
timeInfo(x)
x |
SpatRaster or SpatRasterDataset |
format |
One of "", "seconds" (POSIXlt), "days" (Date), "yearmonths" (decimal years), "years", "months". If "", the returned format is (based on) the format that was used to set the time |
value |
|
tstep |
One of "years", "months", "yearmonths". Used when |
time
: POSIXlt, Date, or numeric
timeInfo
: data.frame with time step and time zone information (if available)
has.time
: logical
depth
s <- rast(system.file("ex/logo.tif", package="terra"))
# Date"
d <- as.Date("2001-05-04") + 0:2
time(s) <- d
time(s)
# POSIX (date/time with a resolution of seconds)
time(s) <- as.POSIXlt(d)
time(s)
# with time zone
time(s) <- as.POSIXlt(Sys.time(), "America/New_York") + 0:2
time(s)
timeInfo(s)
# years
time(s, tstep="years") <- 2000 + 0:2
s
time(s, tstep="months") <- 1:3
s
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.