hydromt.MeshModel.setup_mesh_from_raster_reclass#
- MeshModel.setup_mesh_from_raster_reclass(raster_fn: str | Path | DataArray, reclass_table_fn: str | Path | DataFrame, reclass_variables: list, variable: str | None = None, fill_nodata: str | None = None, resampling_method: str | list | None = 'mean', all_touched: bool | None = True, rename: Dict | None = {}, **kwargs) List[str] #
HYDROMT CORE METHOD: Add data variable(s) to mesh object by reclassifying the data in
raster_fn
based onreclass_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.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_nodata (
str
, optional) – If specified, fills nodata values in raster_fn using the fill_nodata method before reclassifying. Available methods are {‘linear’, ‘nearest’, ‘cubic’, ‘rio_idw’}.resampling_method (
str
orlist
, optional) – Method to sample from raster data to the mesh. Can be a list per variable in reclass_variables or a single method for all. By default, ‘mean’ is used for all reclass_variables. Options include {‘count’, ‘min’, ‘max’, ‘sum’, ‘mean’, ‘std’, ‘median’, ‘q##’}.all_touched (
bool
, optional) – If True, all pixels touched by geometries will be used to define the sample. If False, only pixels whose center is within the geometry or that are selected by Bresenham’s line algorithm will be used. By default, True.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.