hydromt.MeshModel.setup_mesh2d_from_rasterdataset#

MeshModel.setup_mesh2d_from_rasterdataset(raster_fn: str | Path | DataArray | Dataset, grid_name: str | None = 'mesh2d', variables: list | None = None, fill_method: str | None = None, resampling_method: List | str | None = 'centroid', rename: Dict | None = None) List[str]#

HYDROMT CORE METHOD: Add data variable(s) from raster_fn to 2D grid_name in mesh object.

Raster data is interpolated to the mesh grid_name using the resampling_method. If raster is a dataset, all variables will be added unless variables list is specified.

Adds model layers:

  • raster.name mesh: data from raster_fn

Parameters:
  • raster_fn (str, Path, xr.DataArray, xr.Dataset) – Data catalog key, path to raster file or raster xarray data object.

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

  • variables (list, optional) – List of variables to add to mesh from raster_fn. By default all.

  • fill_method (str, optional) – If specified, fills no data values using fill_nodata method. 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 variables.

  • rename (dict, optional) – Dictionary to rename variable names in raster_fn before adding to mesh {‘name_in_raster_fn’: ‘name_in_mesh’}. By default empty.

Returns:

List of variables added to mesh.

Return type:

list