Skip to content
Prev 15274 / 29559 Next

Plot spatial time series

Thiago,

It's not clear to me exactly what your plot would represent.  Is it the 
average of the whole scene? One pixel?

Assuming you're plotting 1 value per raster, I wouldn't try to stack all 
506 files.  I would read one at a time, summarize the values and put 
them into a dataframe.  Here's an idea of what I would try:

temp.df <- data.frame(date = rep(NA, length(files)), lai = NA)
for ( f in files ){
     cat('Reading file: ', f, '\n')
     tmp.df$date <- regmatches(f, regexpr('[0-9]{7}', f))
     tmp.df$lai <- mean(getValues(r), na.rm = TRUE)
}

You could convert date to a Date object, but I don't know off the top of 
my head how to deal with Julian days.

More simply, you could say tmp.df$date <- as.numeric(tmp.df$date), and 
plot would treat it approximately correctly.

Finish up with:

with(tmp.df, plot(date, lai))

Matt
On 6/8/2012 2:10 PM, Thiago Veloso wrote: