hydromt.workflows.grid.grid_from_constant#

hydromt.workflows.grid.grid_from_constant(grid_like: DataArray | Dataset, constant: int | float, name: str, dtype: str | None = 'float32', nodata: int | float | None = None, mask_name: str | None = 'mask') DataArray[source]#

Prepare a grid based on a constant value.

Parameters:
  • grid_like (xr.DataArray, xr.Dataset) – Grid to copy metadata from.

  • constant (int, float) – Constant value to fill grid with.

  • name (str) – Name of grid.

  • dtype (str, optional) – Data type of grid. By default ‘float32’.

  • nodata (int, float, optional) – Nodata value. By default infered from dtype.

  • mask_name (str, optional) – Name of mask in self.grid to use for masking raster_fn. By default ‘mask’. Use None to disable masking.

Returns:

da – Grid with constant value.

Return type:

xr.DataArray