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 0x7f16b8fc1b20>] | None = None, geom: ~geopandas.geodataframe.GeoDataFrame | None = None, zoom: int | tuple | None = None, buffer: float | int = 0, chunks: dict | None = None, 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, json_schema_input_type=PydanticUndefined), ~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 thanxarray.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 Nonegeom (
Optional[gpd.GeoDataFrame]
, optional) – A geometry defining the area of interest, by default Nonezoom (
Optional[Zoom]
,optional,
) – Either an overview_level, or a tuple with the resolution and unit of the resolution.chunks (
Optional[dict]
, optional) – Set the chunking of the data, this overrules the chunking set in the data catalog. If not specified, the chunking defined in the data catalog will be used. By default Nonebuffer (
Union[float
,int]
, optional) – Buffer around the bbox or geom area of interest in meters, by default 0handle_nodata (
NoDataStrategy
, optional) – How to react when no data is found, by default NoDataStrategy.RAISEvariables (
Optional[List]
, optional) – Names of RasterDataset variables to return, or all if None, by default Nonetime_range (
Optional[TimeRange]
, optional) – Start and end date of period of interest, or entire period if None, by default Nonesingle_var_as_array (
bool
, optional) – Wether to return a xr.DataArray if the dataset consists of a single variable, by default Trueprovider (
Optional[str]
, optional) – Specifies a data provider, by default Noneversion (
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