[R-sig-Geo] Displaying temporal variation of raster data
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Thu Mar 15 18:58:35 CET 2012
On Thu, Mar 15, 2012 at 4:45 PM, Thiago Veloso <thi_veloso at yahoo.com.br> wrote:
> Dear Jan (cc Oscar, who also gave a tip),
> Thanks for your input. Sorry for not stating my problem concisely. This time I have shared a simplified sample of my data: http://db.tt/XXDtRee1.
> Notice that this netcdf file contains three time dimensions - corresponding to years 2000 to 2002 (entire dataset contains ten). Also notice that values range from 0 to 1. As we can see in the file, each year is marked by different degrees of deforestation rates.
> Below is the code I am using to load the multi-band file:
>> library (raster)> deforest<-brick("/home/thiago/Dropbox/defor-3-years.nc"
From there, I can go:
> meltR=melt(as.array(deforest))
> meltR$class=cut(meltR$value,c(0,0.3,0.6,1))
> p = ggplot(meltR,aes(x=class))
> p + geom_histogram(aes(fill=class))+facet_grid(~X3)
And get a very pretty set of histograms. You need the ggplot package.
You might want to get rid of the NA values - note that one of the
values in your data is greater than 1, contrary to what you said!
> range(meltR$value,na.rm=TRUE)
[1] 0.000006 1.000662
Barry
More information about the R-sig-Geo
mailing list