[R] raster time series statistics
Alexander.Herr at csiro.au
Alexander.Herr at csiro.au
Tue Mar 6 06:07:20 CET 2018
It works if you use as.Date. But this defeates the purpose for the yearmon notion...
require(raster)
require(rts)
require(stringr)
r <- raster(ncol=100, nrow=100)
values(r) <- runif(ncell(r))
stack(r)->s
r->rs
for(i in 1:23){
rs[]<-r[]*i
addLayer(s,rs)->s
print(nlayers(s))
}
dt<-list(ID=seq(1:24),month=rep(formatC(1:12,flag=0,width=2),2), year=sort(rep(2016:2017,12)))
timelst<-paste0(unlist(dt['year']),'-',unlist(dt['month']),"-01")
strptime(timelst,format="%Y-%m-%d")->t1
rts(s,time=as.yearmon(t1))->rsts
subset(rsts,'2017')->r2017
class(r2017 at time)
class(rsts at time)
apply.monthly(rsts,mean) # this creates error
rts(s,time=as.Date(t1))->rsts1
apply.monthly(rsts1,mean) # this creates output
-----Original Message-----
From: Jim Lemon [mailto:drjimlemon at gmail.com]
Sent: Tuesday, 6 March 2018 11:40 AM
To: Herr, Alexander (L&W, Black Mountain) <Alexander.Herr at csiro.au>
Cc: David Winsemius <dwinsemius at comcast.net>; r-help mailing list <r-help at r-project.org>
Subject: Re: [R] raster time series statistics
More information about the R-help
mailing list