[R-sig-Geo] Plot spatial time series

Tomislav Hengl hengl at spatial-analyst.net
Tue Jun 12 08:40:46 CEST 2012


Connected with this topic, there is now an (experimental) plotKML method 
for spatial series of raster bricks that allows visualization of 
time-series rasters in Google Earth:

http://plotkml.r-forge.r-project.org/RasterBrickTimeSeries-class.html

Here is an example:

http://plotkml.r-forge.r-project.org/Fig_RasterBrickTimeSeries.jpg
http://plotkml.r-forge.r-project.org/LST.ts.kml

plotKML should be soon available via CRAN.

T. Hengl
http://www.wewur.wur.nl/popups/vcard.aspx?id=HENGL001


On 11/06/2012 18:57, Oscar Perpiñán Lamigueiro wrote:
> 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.
>>    Matthew,
>>
>>    Thank you very much for the suggestion. You assumed correctly: I wanted to plot an average of the whole raster.
>>
>>    I managed to plot the data (please see http://img137.imageshack.us/img137/601/screenshotan.png), but it's still precarious. Right now I am tying to improve the plot with ggplot2 package!
>>
>>    Cheers,
>>    Thiago.
>>
>>
>> ----- Original Message -----
>> From: Matt Landis<landis at isciences.com>
>> To: Thiago Veloso<thi_veloso at yahoo.com.br>
>> Cc: R-SIG list<r-sig-geo at r-project.org>
>> Sent: Friday, June 8, 2012 3:45 PM
>> Subject: Re: [R-sig-Geo] Plot spatial time series
>>
>> Fixing typos:
>> tmp.df<- data.frame(date = rep(NA, length(files)), lai = NA)
>> for ( i in 1:length(files) ){
>>       f<- files[i]
>>     cat('Reading file: ', f, '\n')
>>     tmp.df$date[i]<- regmatches(f, regexpr('[0-9]{7}', f))
>>     tmp.df$lai[i]<- mean(getValues(r), na.rm = TRUE)
>> }
>



More information about the R-sig-Geo mailing list