hydromt.workflows.grid.grid_from_rasterdataset#

hydromt.workflows.grid.grid_from_rasterdataset(grid_like: DataArray | Dataset, ds: DataArray | Dataset, variables: List | None = None, fill_method: str | None = None, reproject_method: List | str | None = 'nearest', mask_name: str | None = 'mask', rename: Dict | None = None) Dataset[source]#

Prepare data by resampling ds to grid_like.

If raster is a dataset, all variables will be added unless variables list is specified.

Parameters:
  • grid_like (xr.DataArray, xr.Dataset) – Grid to copy metadata from.

  • ds (xr.DataArray, xr.Dataset) – Dataset with raster data.

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

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

  • reproject_method (list, str, optional) – See rasterio.warp.reproject for existing methods, by default ‘nearest’. Can provide a list corresponding to variables.

  • mask_name (str, optional) – Name of mask in self.grid to use for masking raster_fn. By default ‘mask’. Use None to disable masking.

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

Returns:

ds_out – Dataset with data from ds resampled to grid_like

Return type:

xr.Dataset