2

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

http://eca.knmi.nl/download/ensembles/download.php

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 Mar 26 '14 at 19:20
  • Thanks @mdsumner. After giving up on GDAL, started looking for solutions in R and found them. – Filipe Dias Mar 26 '14 at 20:20
3

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

library(raster)
library(ncdf)
library(stringr)
library(rts)


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


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

as.Date(datas)->datas
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:

http://r-gis.net/?q=rts

1

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, privacy policy and cookie policy

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