hydromt_wflow.workflows.gauges.gauge_map_uparea#

gauge_map_uparea(ds: Dataset, gdf: GeoDataFrame, uparea_name: str | None = 'meta_upstream_area', mask: ndarray | None = None, wdw: int | None = 1, rel_error: float = 0.05, abs_error: float = 50, fillna: bool = False)[source]#

Snap point locations to grid cell.

With smallest difference in upstream area within wdw around the original location if the local cell does not meet the error criteria.

Both the upstream area variable named uparea_name in ds and gdf as well as abs_error should have the same unit (typically km2).

Parameters:
  • ds (xr.Dataset) – Dataset with upstream area variable.

  • gdf (gpd.GeoDataFrame) – GeoDataFrame with gauge points and uparea column.

  • uparea_name (str, optional) – Name of the upstream area variable in ds, by default “meta_upstream_area”.

  • mask (np.ndarray, optional) – Mask cells to apply the uparea snapping, by default None.

  • wdw (int, optional) – Window size around the original location to search for the best matching cell, by default 1.

  • rel_error (float, optional) – Relative error threshold to accept the best matching cell, by default 0.05.

  • abs_error (float, optional) – Absolute error threshold to accept the best matching cell, by default (50 km2).

  • fillna (bool, optional) – Fill NaN values in gdf[“uparea”] with uparea from ds, by default False.

Returns:

  • da (xr.DataArray) – Gauge map with gauge points snapped to the best matching cell.

  • idxs_out (np.ndarray) – Array of indices of the best matching cell.

  • ids_out (np.ndarray) – Array of gauge point ids.