Data¶
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/file.nc")
The data is structured in a DataSet with multiple DataArrays, each representing one of the MSI bands:
satellite_data
<xarray.Dataset> Dimensions: (x: 3001, y: 1601) Coordinates: * 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 ...
xarray.Dataset
- x: 3001
- y: 1601
- y(y)float645.603e+06 5.603e+06 ... 5.587e+06
array([5602695., 5602685., 5602675., ..., 5586715., 5586705., 5586695.])
- x(x)float643.475e+05 3.475e+05 ... 3.775e+05
array([347505., 347515., 347525., ..., 377485., 377495., 377505.])
- B1(y, x)float32...
[4804601 values with dtype=float32]
- B2(y, x)float32...
[4804601 values with dtype=float32]
- B3(y, x)float32...
[4804601 values with dtype=float32]
- B4(y, x)float32...
[4804601 values with dtype=float32]
- B5(y, x)float32...
[4804601 values with dtype=float32]
- B6(y, x)float32...
[4804601 values with dtype=float32]
- B7(y, x)float32...
[4804601 values with dtype=float32]
- B8(y, x)float32...
[4804601 values with dtype=float32]
- B8A(y, x)float32...
[4804601 values with dtype=float32]
- B9(y, x)float32...
[4804601 values with dtype=float32]
- B11(y, x)float32...
[4804601 values with dtype=float32]
- B12(y, x)float32...
[4804601 values with dtype=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
Task¶
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/ahr_hochwasser_before.nc")
sentinel_after = xr.open_dataset("data/ahr_hochwasser_before.nc")
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]