hydromt.model.processes.mesh.mesh2d_from_raster_reclass#

hydromt.model.processes.mesh.mesh2d_from_raster_reclass(da: DataArray, df_vars: DataFrame, mesh2d: UgridDataArray | Ugrid2d, reclass_variables: List[str], fill_method: str | None = None, resampling_method: str | List[str] | None = 'centroid', rename: Dict[str, str] | None = None) UgridDataset[source]#

Resample data to mesh2d grid by reclassifying the data in da based on df_vars.

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

Parameters:
  • da (xr.DataArray) – Raster xarray DataArray object.

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

  • mesh2d (xu.UgridDataArray, xu.Ugrid2d) – Mesh2d grid to resample to.

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

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

  • resampling_method (str, 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_uds_out’}. By default, an empty dictionary.

Returns:

uds_out – Resampled data on mesh2d.

Return type:

xu.UgridDataset