hydromt.data_catalog.DataCatalog.get_rasterdataset#

DataCatalog.get_rasterdataset(data_like: str | ~hydromt._typing.type_def.SourceSpecDict | ~pathlib.Path | ~xarray.core.dataset.Dataset | ~xarray.core.dataarray.DataArray | ~hydromt.data_catalog.sources.rasterdataset.RasterDatasetSource, bbox: ~typing.Annotated[~typing.Tuple[float, float, float, float], <function _validate_bbox at 0x7f35298edd00>] | None = None, geom: ~geopandas.geodataframe.GeoDataFrame | None = None, zoom: int | tuple | None = None, buffer: float | int = 0, handle_nodata: ~hydromt._typing.error.NoDataStrategy = NoDataStrategy.RAISE, variables: ~typing.List | str | None = None, time_range: ~typing.Annotated[~typing.Tuple[~datetime.datetime, ~datetime.datetime], ~pydantic.functional_validators.BeforeValidator(func=~hydromt._typing.type_def._time_range_from_str), ~pydantic.functional_validators.AfterValidator(func=~hydromt._typing.type_def._time_range_validate)] | None = None, single_var_as_array: bool | None = True, provider: str | None = None, version: str | None = None, **kwargs) Dataset | DataArray | None[source]#

Return a clipped, sliced and unified RasterDataset.

To clip the data to the area of interest, provide a bbox or geom, with optional additional buffer argument. To slice the data to the time period of interest, provide the time_range argument. To return only the dataset variables of interest provide the variables argument.

NOTE: Unless single_var_as_array is set to False a single-variable data source will be returned as xarray.DataArray rather than xarray.Dataset.

Parameters:
  • data_like (Union[ str, SourceSpecDict, Path, xr.Dataset, xr.DataArray, RasterDatasetSource ]) – Data catalog key, path to RasterDataset file, a RasterDatasetSource object, or RasterDataset xarray object. The catalog key can be a string or a dictionary with the following keys: {‘name’, ‘provider’, ‘version’}. If a path to a file is provided it will be added to the catalog with its based on the file basename.

  • bbox (Optional[List], optional) – (xmin, ymin, xmax, ymax) bounding box of area of interest (in WGS84 coordinates), by default None

  • geom (Optional[gpd.GeoDataFrame], optional) – A geometry defining the area of interest, by default None

  • zoom (Optional[Zoom], optional,) – Either an overview_level, or a tuple with the resolution and unit of the resolution.

  • buffer (Union[float, int], optional) – Buffer around the bbox or geom area of interest in meters, by default 0

  • handle_nodata (NoDataStrategy, optional) – How to react when no data is found, by default NoDataStrategy.RAISE

  • variables (Optional[List], optional) – Names of RasterDataset variables to return, or all if None, by default None

  • time_range (Optional[TimeRange], optional) – Start and end date of period of interest, or entire period if None, by default None

  • single_var_as_array (bool, optional) – Wether to return a xr.DataArray if the dataset consists of a single variable, by default True

  • provider (Optional[str], optional) – Specifies a data provider, by default None

  • version (Optional[str], optional) – Specifies a data version, by default None

  • **kwargs – Extra keyword arguments passed to the RasterDatasetSource construction

Returns:

a clipped, sliced and unified RasterDataset

Return type:

xr.Dataset

Raises:
  • ValueError – If data_like is of an unknown type

  • NoDataException – If no data is found and handle_nodata is NoDataStrategy.RAISE