View source: R/subset_datacube.R
subset_datacube | R Documentation |
This function subsets a datacube (RasterStack or RasterBrick) based on dates.
subset_datacube(r, from, to)
r |
is the Raster layer to compare to the climatology. |
from |
string, starting date (e.g. "2018-12-30"). |
to |
string, ending date (e.g. "2018-12-31"). |
If the from
and to
strings are in the format
"YYYY-MM-DD", they are automatically converted into a date.
The function returns a subset of r
, with layer's date in the
range starting with from
and ending with to
.
## Not run: r <- raster(nrows = 2, ncols = 2, xmn = 0, xmx = 360, ymn = -90, ymx = 90, vals = 30) # Generate dummy RasterBrick b <- raster::brick(lapply(1:(365 * 3), function(i) raster::setValues(r, unif(n = raster::ncell(r), min = 0, max = 100)))) raster::setZ(b) <- seq.Date(from = as.Date("1993-01-01"), to = as.Date("1995-12-31"), by = "day") subset_datacube(r = b, from = "1993-01-01", to = "1993-01-01") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.