hydromt.model.components.MeshComponent.add_2d_data_from_rasterdataset#
- MeshComponent.add_2d_data_from_rasterdataset(raster_filename: str | Path | DataArray | Dataset, *, grid_name: str = 'mesh2d', variables: List[str] | None = None, fill_method: str | None = None, resampling_method: List | str | None = 'centroid', rename: Dict[str, str] | None = None) List[str] [source]#
HYDROMT CORE METHOD: Add data variable(s) from
raster_filename
to 2Dgrid_name
in mesh object.Raster data is interpolated to the mesh
grid_name
using theresampling_method
. If raster is a dataset, all variables will be added unlessvariables
list is specified.Adds model layers:
raster.name mesh: data from raster_filename
- Parameters:
raster_filename (
str
,Path
,xr.DataArray
,xr.Dataset
) – Data catalog key, path to raster file or raster xarray data object.grid_name (
str
) – 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_filename. 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 usexugrid.CentroidLocatorRegridder()
method. If barycentric, will usexugrid.BarycentricInterpolator()
method. If any other, will usexugrid.OverlapRegridder()
method. Can provide a list corresponding tovariables
.rename (
dict
, optional) – Dictionary to rename variable names in raster_filename before adding to mesh {‘name_in_raster_filename’: ‘name_in_mesh’}. By default empty.
- Returns:
List of variables added to mesh.
- Return type: