 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")> deforestclass       : RasterBrick dimensions  : 47, 68, 3196, 3  (nrow, ncol, ncell, nlayers)resolution  : 0.5, 0.5  (x, y)extent      : -74.5, -40.5, -18, 5.5  (xmin, xmax, ymin, ymax)coord. ref. : +proj=longlat +datum=WGS84 values      : /home/thiago/Dropbox/defor-3-years.nc zvar        : 2000 
 My objective is to show, in a single plot, the frequency of data in classes (0 to 0.3, 0,31 to 0.6 and 0.61 to 1) for each year (each "rasterbrick" object). What I have in mind is a graphic like this (which I sketched using hypothetical data, just to illustrate the idea): http://img24.imageshack.us/img24/6416/examplezxt.png .
 Thanks for any tips!
 Best, Thiago.
--- On Thu, 15/3/12, Jan Verbesselt <janverbesselt@gmail.com> wrote:

From: Jan Verbesselt <janverbesselt@gmail.com>
Subject: Re: [R-sig-Geo] Displaying temporal variation of raster data
To: "Thiago Veloso" <thi_veloso@yahoo.com.br>
Cc: "R SIG list" <r-sig-geo@stat.math.ethz.ch>
Date: Thursday, 15 March, 2012, 5:03

Hi Thiago,

yes, certainly. Without an R script or data is it not so easy to help you. Here are some tips and packages which might be helpful:

- raster package; reading netcdf files
- use getValues() from the raster package to extract the data
- ggplot2 package for creating great graphs
- see http://had.co.nz/ggplot2/geom_bar.html for categorical histogram examples.
- maybe melt() of the ggplot2 package might be handy to prepare your data set.

A very simple example:
library(raster) 
library(ggplot2)
m <- matrix(1:100, nr=10)
n <- matrix(c(rep(1,30),rep(2,70)), nr=10)
r <- raster(m, xmn=167620, xmx=171745, ymn=443660, ymx=448110) 
deforest <- raster(n, xmn=167620, xmx=171745, ymn=443660, ymx=448110)
df <- data.frame(rate=getValues(r), class=getValues(deforest))
ggplot(df, aes(x=factor(class), fill=factor(class))) + geom_bar()


Cheers,
Jan

On 15/03/2012, at 3:34 AM, Thiago Veloso wrote:

> Dear R colleagues,
> 
> I have a netcdf file containing ten time slices, where each slice corresponds to yearly deforestation rates over the Amazon forest. Values range from 0 (no deforest) to 1 (maximum deforest). Please take a look in a sample of the data: http://imageshack.us/photo/my-images/23/deforestamazon.png/
> 
> My objective is to show the temporal variation of this data. How can I produce categorical histograms for each one of the ten years? What I have in mind is something like the lower panel of this figure: http://www.crwr.utexas.edu/gis/gishydro05/Time/DHI_Temporal_Analyst/TemporalAnalystForArcGIS.htm, but plotting bars relative to three or four classes of deforesting rates instead of lines.
> 
> Is it possible to produce such a figure using any SIG-related R package?
> 
> Many thanks in advance,
> Thiago.
> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo


	[[alternative HTML version deleted]]

