Skip to content
Prev 15289 / 29559 Next

Plot spatial time series

Thiago Veloso <thi_veloso at yahoo.com.br> writes:
Hello,

Another approach is to use the zoo package with setZ and cellStats. 

With a toy example:

library(raster)
library(zoo)

fn <- system.file("external/test.grd", package="raster")
r <- raster(fn)
ll <- lapply(runif(12), function(x)r*x)
s <- stack(ll)

idx <- as.yearmon(2011 + seq(0, 11)/12)
s <- setZ(s, idx)
avg <- zoo(cellStats(s), idx)

## plot method for the zoo objects
plot(avg)

## or with lattice, xyplot method for the zoo objects
library(lattice)
xyplot(avg)

Best,

Oscar.

  
    
Message-ID: <87wr3ei5tw.fsf@gmail.com>
In-Reply-To: <1339264219.96874.YahooMailNeo@web161401.mail.bf1.yahoo.com> (Thiago Veloso's message of "Sat, 9 Jun 2012 10:50:19 -0700 (PDT)")