[R-sig-Geo] How to calculate seasonal means in raster time series?
Thiago V. dos Santos
thi_veloso at yahoo.com.br
Wed Aug 17 02:38:50 CEST 2016
Dear all,
I am using the raster package to calculate seasonal averages of climatic variables. I usually use zApply to perform temporal calculations on gridded time series.
However, this time I need to calculate seasonal averages according to the meteorological nomenclature, with DJF (=winter in the southern hemisphere: December, January, February), MAM, JJA, and SON. It is similar to zoo's yearqtr, but with a offset of -1 month on each quarter.
That means that December values comes from the previous year.
This is a typical raster I work with:
library(raster)
# Create date sequence
idx <- seq(as.Date("2001/1/1"), as.Date("2010/12/31"), by = "day")
# Create raster stack and assign dates
r <- raster(ncol=5, nrow=5)
s <- stack(lapply(1:length(idx), function(x) setValues(r, runif(ncell(r)))))
s <- setZ(s, idx)
On a raster stack like this, what would be the best strategy to calculate "meteorological" seasonal means?
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