hydromt.workflows.grid.grid_from_raster_reclass#

hydromt.workflows.grid.grid_from_raster_reclass(grid_like: DataArray | Dataset, da: DataArray, reclass_table: DataFrame, reclass_variables: List, fill_method: str | None = None, reproject_method: List | str | None = 'nearest', mask_name: str | None = 'mask', rename: Dict | None = None) Dataset[source]#

Prepare data variable(s) resampled to grid_like object by reclassifying the data in da based on reclass_table.

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

  • da (xr.DataArray) – DataArray with classification raster data.

  • reclass_table (pd.DataFrame) – Tabular pandas dataframe object for the reclassification table of da.

  • reclass_variables (list) – List of reclass_variables from reclass_table_fn table to add to maps. Index column should match values in raster_fn.

  • fill_method (str, optional) – If specified, fills nodata values in raster_fn using fill_nodata method before reclassifying. Available methods are {‘linear’, ‘nearest’, ‘cubic’, ‘rio_idw’}.

  • reproject_method (str, optional) – See rasterio.warp.reproject for existing methods, by default “nearest”. Can provide a list corresponding to reclass_variables.

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

  • rename (dict, optional) – Dictionary to rename variable names in reclass_variables before adding to grid {‘name_in_reclass_table’: ‘name_in_grid’}. By default empty.

Returns:

ds_out – Dataset with reclassified data from reclass_table to da resampled to grid_like.

Return type:

xr.Dataset