Eduard Szöcs

Data in Environmental Science and Eco(toxico-)logy

Reading REGNIE DWD data into R

Update (10. Jan 2017):

I fixed a bug in read_regnie() [it was not able to read rasters with >99mm precipitation]. The new functions is also 4.5x faster, then the old function. Check out the new version on github. I will also submit esmisc to CRAN.

Update (25. Feb. 2016):

The DWD has published a python3 script to process the REGNIE data, see the documentation here. I cross-checked esmisc::read_regnie() and they both give the same results.


Recently, I needed some rainfall data for an analysis of pesticide occurrences. The German Meteorological Service (DWD) provides the REGNIE dataset (temporal resolution 24h, spatial resolution 1km) for free (can be downloaded here). REGNIE is a gridded dataset covering whole Germany and is produced by interpolation from station observations (via multiple regression), see the description (german) for more details.

For my recent project, I needed to extract daily precipitation from lots of such grids. Therefore, I wrote a small function to read the REGNIE data into R as a raster object. The function unpacks the .gz archive, deals with missing values and sets the CRS to longlat. Currently, the function is available in my esmisc package.

An example

Here, I read the daily precipitation on Christmas 2014. First, install the esmisc package:

# get the newest version of esmisc
require(devtools)
install_github('EDiLD/esmisc')

I downloaded the file from the FTP (see link above), but it is also shipped with the package. To read the file you can simply use (for downloaded data just use the path to the .gz file):

require(esmisc)
# read the file shipped with esmisc
r <- read_regnie(system.file("extdata", "ra050120.gz", package = "esmisc"))
# plot the raster
require(raster)
plot(r, main = 'Precipitation on 20.01.2005')

plot of chunk regnie

Et viola, the precipitation values are given in mm and the CRS is longlat. In a next step you could reproject the raster (using the projectRaster() function [slow, but R] or gdalwarp [faster]) or extract values from the raster (using extract()).

Written on February 25, 2016