[R-sig-Geo] How to perform cross-year date operations on rasters?
Thiago V. dos Santos
thi_veloso at yahoo.com.br
Wed Nov 4 23:37:40 CET 2015
Dear all,
Consider that I have a raster stack with daily values. How can I perform date operations covering a time interval that crosses years?
For example, I want to sum the values from every october-to-january period in this sample raster:
library(raster)
# Create a rasterStack similar to cmip5 - same dimensions and layer names
r <- raster(ncol=180, nrow=90)
s <- stack(lapply(1:1825, function(x) setValues(r, runif(ncell(r)))))
# Apply time stamps to raster
#x <- as.Date(c("2010-01-01","2014-12-31"),format="%Y-%m-%d")
#difftime(x[2], x[1], units="days")
idx <- seq(as.Date("2010/1/1"), by = "day", length.out = 1825)
s <- setZ(s, idx)
s
Thanks in advance,
-- Thiago V. dos Santos
PhD student
Land and Atmospheric Science
University of Minnesota
More information about the R-sig-Geo
mailing list