[R-sig-Geo] Displaying temporal variation of raster data
Jan Verbesselt
janverbesselt at gmail.com
Thu Mar 15 09:03:01 CET 2012
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 at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list