0

What's the best option to express years in Raster Time Series object in R. I define years as dates:

YEARSSEQ <-seq(as.Date("2008-01-01"), as.Date("2009-01-01"), "year")

and then I pass them in rts constructor function

myrts<-rts(myrasterstack,YEARSSEQ)

Passing as

YEARSSEQ = c("2008", "2009") 

returns the error

  time must be one of time-based classes including: 'POSIXct', 'POSIXt', 'Date', 'timeDate', 'yearmon','yearqtr'

Is there any better option?

  • You haven't defined anything as dates: all your examples are strings. You need to convert the strings to some kind of date as explained by the error message. You can do that directly with, say, strptime and as.POSIXct: the help page for the former is particularly useful. – whuber Jan 29 '18 at 21:33
  • Where does the rts function come from? – Spacedman Jan 29 '18 at 22:26
  • rts function comes from Raster Time Series Analysis package. – Leonidas Liakos Jan 30 '18 at 14:28
  • Just place the right code about YEARSSEQ as dates. – Leonidas Liakos Jan 30 '18 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.