Purpose
hydflood is an R package designed to compute flood extent and duration along the German federal waterways Elbe and Rhine.
Use
Installation
The package hydflood is available from CRAN. To install it run:
install.packages("hydflood")
To install the recent developmental version from Github execute the following commands:
install.packages("devtools")
library(devtools)
devtools::install_github("bafg-bund/hydflood")
Afterwards hydflood can be loaded like every other R package with the following command:
Dependencies
The package hydflood is built around the packages terra
and hyd1d
. hyd1d
internally provides
gauging data for all gauging stations along the rivers Rhine and Elbe
operated by the German Waterway and Shipping Administration and computes
1D water levels. The package terra
provides the S4 class SpatRaster
and thereby enables the
GIS based comparison between extrapolated water levels and elevation
data.
hydflood provides download facilities for the
digital elevation models of the waterways Rhine and Elbe (DEM, Weber (2020))
with 1 m spatial resolution for chosen extents. If necessary,
alternative dem
’s can be supplied by users. They just need
to overlap with active floodplains of either the Rhine (sf.afr
)
or the Elbe (sf.afe
).
To create a water surface raster, which can be compared to the
dem
, a simple 1D to 2D conversion is applied to water level
data computed along the river axis with the package hyd1d
. Therefore so
called cross section areas (csa
) are needed. They originate
from cross sections used for the SOBEK models run for and incorporated
into FLYS.
These cross sections, one for each individual river station,
represent water level isolines perpendicular to the rivers axis. To
enable the spatial extrapolation of water level information for each
river station, they were converted to cross section areas
(csa
) which are similar to stairs along the river axis,
each step corresponding to a station of the 1D WaterLevelDataFrame
computed by the waterLevel
function of package hyd1d
. To accelerate the
computations, while keeping the package size on CRAN small, cross section areas
are downloaded once for each river by package internal facilities during
their first use.
Computation of flood extents and durations
The actual computation of a flood extent in a selected computational domain for a given time can be split into five steps:
- Extraction of relevant stations within the computational domain
- Creation of a
WaterLevelDataFrame
for the selected river section - Computation of the 1D water level using the
waterLevel
function of packagehyd1d
- Transfer of the 1D water level information from the
WaterLevelDataFrame
to the cross section areas (csa
) through the join fieldstation_int
- Computation of a binary flood raster
fd
through the equationfd[csa > dem] = fd[csa > dem] + 1
To compute flood durations these five steps are repeated for every given time step, so that the resulting raster contains counts of how often each individual raster cell was flooded. The possible range of values is between 0 and the number of time steps given.
Usage
To initialize such a SpatRaster
several possibilities
are implemented in the initializing homonymous function
hydSpatRaster
. Either you provide a digital elevation model
and cross section areas yourself as variables filename_dem
and filename_csa
or you provide only one of them or you
simply provide ext
(an object of type
SpatExtent
) and crs
(an object of class
CRS
). Depending on the supplied coordinate reference system
(supplied through either filename_dem
,
filename_csa
or crs
) the respective river is
selected: For the River Rhine data with ‘ETRS 1989 UTM 32N’ (EPSG 25832) have to
be supplied, for the River Elbe ‘ETRS 1989 UTM 32N’ (EPSG 25833). If you
can’t provide dem and csa yourself, hydflood
provides csa
data internally and downloads the official digital elevation models of
the German Waterway and Shipping Administration with 1 m spatial
resolution. Therefore you definitely need internet access and, due to
the data volume of the elevation data, your internet should be fast or
you should be patient.
# import the raster data and create a raster stack
x <- hydSpatRaster(filename_dem = "data-raw/raster.dem.tif",
filename_csa = "data-raw/raster.csa.tif")
After initialinzig an object of type hydSpatRaster
everything else is straight forward. Create a temporal sequence
seq
:
And supply both of them to the flood3
function, which
will do the computation and return an ‘INT4S’ raster with counts of how
often the individual cell of the dem
was lower than the
csa
during the temporal sequence. For each time step of the
temporal sequence the corresponding 1D WaterLevelDataFrame
is computed, joined to csa
through the
station_int
column and compared to the dem
so
that the possible values of the returned product range between 0 and
length(seq)
:
Products
Raster data
Raster data with annual flood durations between 1960 and 2021 for the active floodplains of the River Rhine and the River Elbe have been submitted to and published on pangaea.de (Weber, 2022, 2023).
ShinyApps
flood3daily
The flood3
function is the central function of the package
hydflood. With the help of this function daily flood
extents are computed for a number of areas along the River Elbe. These
products are visualized through a shiny web application available
through:
https://shiny.bafg.de/flood3daily/
flood3wms
The flood3
function is the central function of the package
hydflood. With the help of this function annual flood
durations between 1990 and 2022 have been computed for the active
floodplains of the River Rhine and the River Elbe. These large scale
raster products have been visualized as web map services and are
available through a shiny web application:
https://shiny.bafg.de/flood3wms/