hydromt_sfincs.workflows.downscaling.downscale_floodmap#

hydromt_sfincs.workflows.downscaling.downscale_floodmap(zsmax: ~xarray.core.dataarray.DataArray | ~xugrid.core.wrap.UgridDataArray, dep: ~pathlib.Path | str | ~xarray.core.dataarray.DataArray, reproj_method: str = 'nearest', subtract_dem: bool = True, indices: ~pathlib.Path | str | ~xarray.core.dataarray.DataArray = None, hmin: float = 0.05, gdf_mask: ~geopandas.geodataframe.GeoDataFrame = None, floodmap_fn: ~pathlib.Path | str = None, zsmap_fn: ~pathlib.Path | str = None, zoom_level: int | tuple | None = None, nrmax: int = 2000, logger=<Logger hydromt.hydromt_sfincs.workflows.downscaling (WARNING)>, **kwargs)[source]#

Create a downscaled floodmap for (model) region.

The downscaler assigns every high-resolution DEM pixel a water-surface elevation (WSE) interpolated from the SFINCS zsmax field and — by default — subtracts the DEM to obtain flood depth. Its behaviour is set by two orthogonal knobs:

  • reproj_method – how the WSE is interpolated onto the DEM grid: "nearest" (each pixel takes the WSE of the SFINCS cell that contains it — the classic bathtub) or "bilinear" (interpolate between surrounding cell centres, Sanders & Schubert 2019).

  • subtract_dem – when True (default) the DEM is subtracted to return flood depth hmax; when False the raw interpolated water level is returned (no DEM subtraction, no hmin masking).

WSE pre-adjustments (cell-space dilation, Bernoulli velocity head) are not part of this function — call adjust_zsmax_dilation() / adjust_zsmax_energyhead() on zsmax beforehand if needed.

Parameters:
  • zsmax (xr.DataArray or xu.UgridDataArray) – Maximum water level (m). When multiple timesteps are present the maximum over all timesteps is used.

  • dep (Path, str, or xr.DataArray) – High-resolution DEM (m) of the model region.

  • reproj_method ({"nearest", "bilinear"}, optional) – WSE interpolation onto the DEM grid, by default "nearest". On a regular grid "bilinear" uses the reproject engine; on a quadtree it uses a scattered interpolator over the cell centres.

  • subtract_dem (bool, optional) – Subtract the DEM to return flood depth (True, default) or return the raw interpolated water level (False).

  • indices (Path, str, or xr.DataArray, optional) – Pre-computed cell-index raster (exact containment; used for reproj_method="nearest" and to mask pixels outside the domain).

  • hmin (float, optional) – Minimum water depth (m) to be considered flooded, by default 0.05. Ignored when subtract_dem is False.

  • gdf_mask (gpd.GeoDataFrame, optional) – Polygons to mask the output (area outside is set to NaN).

  • floodmap_fn (Path or str, optional) – Output flood-depth GeoTIFF. Required (for file input) when subtract_dem is True.

  • zsmap_fn (Path or str, optional) – Output water-level GeoTIFF. Required (for file input) when subtract_dem is False.

  • zoom_level (int or tuple, optional) – Overview level of the raster dataset (regular-grid nearest only).

  • nrmax (int, optional) – Block size in pixels, by default 2000.

  • logger (logging.Logger, optional) – Logger instance.

  • kwargs (dict, optional) – Extra keyword arguments forwarded to RasterDataArray.to_raster (only for the in-memory path).

Returns:

The downscaled product: flood depth (hmax) when subtract_dem is True, otherwise the water level. Dry pixels are NaN (a domain with no flooding yields an all-NaN array). File-based calls also write it to floodmap_fn / zsmap_fn and return a lazy (dask-backed) view re-opened from that file; the in-memory path returns the array directly.

Return type:

xr.DataArray