hydromt.workflows.mesh.mesh2d_from_rasterdataset#

hydromt.workflows.mesh.mesh2d_from_rasterdataset(ds: ~xarray.core.dataarray.DataArray | ~xarray.core.dataset.Dataset, mesh2d: ~xugrid.core.wrap.UgridDataArray | ~xugrid.ugrid.ugrid2d.Ugrid2d, variables: ~typing.List | None = None, fill_method: str | None = None, resampling_method: str | None = 'centroid', rename: ~typing.Dict | None = None, logger: ~logging.Logger = <Logger hydromt.workflows.mesh (WARNING)>) UgridDataset[source]#

Resamples data in ds to mesh2d.

Raster data is interpolated to the mesh using the resampling_method.

Parameters:
  • ds (xr.DataArray, xr.Dataset) – Raster xarray data object.

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

  • variables (list, optional) – List of variables to resample. By default all variables in ds.

  • 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, 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 ds {‘name_ds’: ‘name_in_uds_out’}. By default empty.

Returns:

uds_out – Resampled data on mesh2d.

Return type:

xu.UgridDataset