The satellite and ground truth data for this case study can be downloaded here:

Read netCDF files (satellite data)

The Sentinel-2 data is provided in netcdf-Format and can be read into python via:

import xarray as xr

satellite_data = xr.open_dataset("path/to/")

The data is structured in a DataSet with multiple DataArrays, each representing one of the MSI bands:

Dimensions:  (x: 3001, y: 1601)
  * y        (y) float64 5.603e+06 5.603e+06 5.603e+06 ... 5.587e+06 5.587e+06
  * x        (x) float64 3.475e+05 3.475e+05 3.475e+05 ... 3.775e+05 3.775e+05
Data variables:
    B1       (y, x) float32 ...
    B2       (y, x) float32 ...
    B3       (y, x) float32 ...
    B4       (y, x) float32 ...
    B5       (y, x) float32 ...
    B6       (y, x) float32 ...
    B7       (y, x) float32 ...
    B8       (y, x) float32 ...
    B8A      (y, x) float32 ...
    B9       (y, x) float32 ...
    B11      (y, x) float32 ...
    B12      (y, x) float32 ...

Read GeoTiffs (labels and DEM)

The label data (flooded areas) and the DEM are provided as GeoTiff and can be opened via:

labels = xr.open_dataset("path/to/file.tif", engine="rasterio").band_data[0]
dem    = xr.open_dataset("path/to/file.tif", engine="rasterio").band_data[0]

Pixel values in the label data have the following meaning:

  • 1: Flooded areas

  • 0: Non-flooded areas

  • -1: No data


Use xarray to load all provided data sets (Sentinel-2 scenes, DEM and labels) and get familiar with the data.

import xarray as xr

sentinel_before = xr.open_dataset("data/")
sentinel_after = xr.open_dataset("data/")

flooded_train = xr.open_dataset("data/ahr_hochwasser_flooded_areas.tif", engine="rasterio").band_data[0]
flooded_test  = xr.open_dataset("data/ahr_hochwasser_flooded_areas_test.tif", engine="rasterio").band_data[0]

dem = xr.open_dataset("data/dem_utm32n_clipped_cropped.tif", engine="rasterio").band_data[0]