Displaying 6 results from an estimated 6 matches for "timelst".
2018 Mar 05
4
raster time series statistics
...quire(stringi)
r <- raster(ncol=100, nrow=100)
values(r) <- runif(ncell(r))
list(ID=seq(1:24),month=rep(str_pad(1:12, pad = 0,width = 2 , "left"),2),year=sort(rep(2016:2017,12)))->dt
stack(r)->s
r->rs
for(i in 1:23){
rs[]<-r[]*i
addLayer(s,rs)->s
print(nlayers(s))
}
timelst<-paste0(unlist(dt['year']),'-',unlist(dt['month']))
rts(s,time=as.yearmon(timelst))->rsts
str(rsts at time)
apply.monthly(rsts,mean)
I was expecting that the statistics accept the yearmonth format of the timeslot, as it allows subsetting.
Any suggestions?
Thanks
Herry...
2018 Mar 06
0
raster time series statistics
Hi Herry,
This is probably due to a call to strptime (or similar). No, it
doesn't accept %Y-%m as a valid format. Maybe add a constant day to
all the dates as that will work:
dt<-list(ID=seq(1:24),month=rep(formatC(1:12,flag=0,width=2),2),
year=sort(rep(2016:2017,12)))
timelst<-paste(unlist(dt['year']),unlist(dt['month']),"01",sep="-")
strptime(timelst,format="%Y-%m-%d")
Jim
On Tue, Mar 6, 2018 at 10:28 AM, <Alexander.Herr at csiro.au> wrote:
> Hi List,
>
> The following code returns an "Error in a...
2018 Mar 06
2
raster time series statistics
...r)
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)
-----O...
2018 Mar 06
0
raster time series statistics
...> values(r) <- runif(ncell(r))
> list(ID=seq(1:24),month=rep(str_pad(1:12, pad = 0,width = 2 , "left"),2),year=sort(rep(2016:2017,12)))->dt
> stack(r)->s
> r->rs
> for(i in 1:23){
> rs[]<-r[]*i
> addLayer(s,rs)->s
> print(nlayers(s))
> }
> timelst<-paste0(unlist(dt['year']),'-',unlist(dt['month']))
> rts(s,time=as.yearmon(timelst))->rsts
> str(rsts at time)
> apply.monthly(rsts,mean)
>
> I was expecting that the statistics accept the yearmonth format of the timeslot, as it allows subsetting.
>...
2018 Mar 06
0
raster time series statistics
...0, 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)
>
&...
2018 Mar 06
1
raster time series statistics
...er)
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 cr...