[R-sig-Geo] zApply

KaTe tersagokatrien at gmail.com
Wed Apr 24 16:34:34 CEST 2013

Dear R-sig-geo, 
I have a problem with the use of zApply on a large Rasterbrick made from a
netcdf file. 
It concerns a file with daily rainfall data for a period of 15 years on a
european scale (see details below)

class       : RasterBrick 
dimensions  : 201, 464, 93264, 6575  (nrow, ncol, ncell, nlayers)
resolution  : 0.25, 0.25  (x, y)
extent      : -40.5, 75.5, 25.25, 75.5  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
names       : X1995.01.01, X1995.01.02, X1995.01.03, X1995.01.04,
X1995.01.05, X1995.01.06, X1995.01.07, X1995.01.08, X1995.01.09,
X1995.01.10, X1995.01.11, X1995.01.12, X1995.01.13, X1995.01.14,
X1995.01.15, ... 
Date        : 1995-01-01, 2012-12-31 (min, max)
varname     : rr 

Now, I want to change this brick with daily data into a brick of monthly
means (per year) prior to data extraction. I am quite convinced I should use
zApply for this, but up till now I was not able to use (read: fully
understand) the few examples from the raster manual or this list
I tried the code below, with RR being the raster brick: 

index<- seq(as.Date('1995-01-01'), as.Date('2012-12-31'), by='day')
system.time(RRmonths<-zApply(RR,by="month", FUN=mean))

when I try this on a subset of 2 years I only get a single raster file, so
clearly something is wrong. 
Even if this works, I fear this code will give me the monthly averages over
the whole series, while I need mean monthly values per year (using yearmon
gives errors). 

I am new to this field, hope anyone could give me some hints to move
forward. (Or some other approach )
Thanks in advance,
PhD, University of Antwerp

View this message in context: http://r-sig-geo.2731867.n2.nabble.com/zApply-tp7583405.html
Sent from the R-sig-geo mailing list archive at Nabble.com.

More information about the R-sig-Geo mailing list