brry / rdwd

download climate data from DWD (German Weather Service)
https://bookdown.org/brry/rdwd
72 stars 13 forks source link

add use case: values at locations in grid #27

Closed brry closed 3 years ago

brry commented 3 years ago

Add use case to website

library(rdwd)

# select data
index <- indexFTP(folder="annual/air_temperature_max", base=gridbase)
index <- index[-(1:2)] # exclude description files
index <- index[as.numeric(substr(index,62,65))>=2013] # after year 2013
index

# download & read data:
tempmax <- dataDWD(index, base=gridbase, joinbf=TRUE)
names(tempmax) <- substr(names(tempmax), 62, 65)

# visual data & projection check:
plotRadar(tempmax[[1]], proj="seasonal",extent="seasonal", 
          main="Annual grid of monthly averaged daily maximum air temperature (2m) - 2013")

# raster stack
tempmax_stack <- raster::stack(tempmax)
tempmax_stack <- projectRasterDWD(tempmax_stack, proj="seasonal",extent="seasonal")
tempmax_stack
raster::plot(tempmax_stack, zlim=range(raster::cellStats(tempmax_stack, range)) )

loc <- data.frame(x=12.65295, y=53.06547) # Aussichtspunkt Kyritz-Ruppiner Heide
raster::extract(tempmax_stack, loc)