hydromt.MeshModel.setup_mesh2d_from_raster_reclass#

MeshModel.setup_mesh2d_from_raster_reclass(raster_fn: str | Path | DataArray, reclass_table_fn: str | Path | DataFrame, reclass_variables: list, grid_name: str | None = 'mesh2d', variable: str | None = None, fill_method: str | None = None, resampling_method: str | list | None = 'centroid', rename: Dict | None = None, **kwargs) List[str]#

HYDROMT CORE METHOD: Add data variable(s) to 2D grid_name in mesh object by reclassifying the data in raster_fn based on reclass_table_fn.

The reclassified raster data are subsequently interpolated to the mesh using resampling_method.

Adds model layers:

  • reclass_variables mesh: reclassified raster data interpolated to the

    model mesh

Parameters:
  • raster_fn (str, Path, xr.DataArray) – Data catalog key, path to the raster file, or raster xarray data object. Should be a DataArray. If not, use the variable argument for selection.

  • reclass_table_fn (str, Path, pd.DataFrame) – Data catalog key, path to the tabular data file, or tabular pandas dataframe object for the reclassification table of raster_fn.

  • reclass_variables (list) – List of reclass_variables from the reclass_table_fn table to add to the mesh. The index column should match values in raster_fn.

  • grid_name (str, optional) – Name of the mesh grid to add the data to. By default ‘mesh2d’.

  • variable (str, optional) – Name of the raster dataset variable to use. This is only required when reading datasets with multiple variables. By default, None.

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

  • resampling_method (str or list, optional) – Method to sample from raster data to mesh. By default mean. Options include {“centroid”, “barycentric”, “mean”, “harmonic_mean”, “geometric_mean”, “sum”, “minimum”, “maximum”, “mode”, “median”, “max_overlap”}. If centroid, will use xugrid.CentroidLocatorRegridder() method. If barycentric, will use xugrid.BarycentricInterpolator() method. If any other, will use xugrid.OverlapRegridder() method. Can provide a list corresponding to reclass_variables.

  • rename (dict, optional) – Dictionary to rename variable names in reclass_variables before adding them to the mesh. The dictionary should have the form {‘name_in_reclass_table’: ‘name_in_mesh’}. By default, an empty dictionary.

  • **kwargs (dict) – Additional keyword arguments to be passed to the raster dataset retrieval method.

Returns:

variable_names – List of added variable names in the mesh.

Return type:

List[str]

Raises:

ValueError – If raster_fn is not a single variable raster.