I downloaded a NetCDF file that contains daily precipitation values from 1-1-1950 to 30-6-2013. The raster has 23191 bands.


My goal is to analyze how precipitation values varied and relate the changes with the conservation of a forest ecosystem.

I'm unsure on how to proceed, but I think the first step should be to create a time series from the NetCDF raster.

How can I do this using GDAL, GRASS GIS or R?

  • In R, start with library(raster);(ncdata <- brick("file.nc")) and report back on what you get. You'll need either ncdf4 or ncdf packages also installed for raster to use.
    – mdsumner
    Commented Mar 26, 2014 at 19:20
  • Thanks @mdsumner. After giving up on GDAL, started looking for solutions in R and found them. Commented Mar 26, 2014 at 20:20

2 Answers 2


Answering to myself. Using R and package "rts" it is possible to create a time series:


stack<-stack("pp_0.25deg_reg_v9.0.nc") #Create raster stack

for (i in 1:length(stack@layers)) {
  word<-str_sub(as.character(stack@layers[[i]]@data@names), start=2, end=11L)
  datas[[length(datas)+1]] <- word
} ##extract the strings with the dates and format them according to as.Date() requirements

rt <- rts(stack,datas) #Create raster stack time series

apply.yearly(rt, mean)->y # calculate the mean (annual) precipitation value

For additional information go to:



You may want to enjoy the new temporal GIS framework in GRASS GIS 7:

An initial release of GRASS GIS 7 has been done two days ago at the Vienna OSGeo Code sprint: http://trac.osgeo.org/grass/wiki/Release/7.0.0beta-News

Time series aggregation, algebra and much more are now provided.

The examples in the aforementioned presentations are based on ECA&D.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.