hydromt.data_catalog.DataCatalog.get_rasterdataset#

DataCatalog.get_rasterdataset(data_like: str | SourceSpecDict | Path | Dataset | DataArray, bbox: List | None = None, geom: GeoDataFrame | None = None, zoom_level: int | tuple | None = None, buffer: float | int = 0, handle_nodata: NoDataStrategy = NoDataStrategy.RAISE, align: bool | None = None, variables: List | str | None = None, time_tuple: Tuple | None = None, single_var_as_array: bool | None = True, provider: str | None = None, version: str | None = None, **kwargs) Dataset | 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 and align arguments. To slice the data to the time period of interest, provide the time_tuple 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 (str, Path, Dict, xr.Dataset, xr.Datarray) – DataCatalog key, path to raster file or raster xarray data object. The catalog key can be a string or a dictionary with the following keys: {‘name’, ‘provider’, ‘version’}. If a path to a raster file is provided it will be added to the catalog with its based on the file basename.

  • bbox (array-like of floats) – (xmin, ymin, xmax, ymax) bounding box of area of interest (in WGS84 coordinates).

  • geom (geopandas.GeoDataFrame/Series,) – A geometry defining the area of interest.

  • zoom_level (int, tuple, optional) – Zoom level of the xyz tile dataset (0 is base level) Using a tuple the zoom level can be specified as (<zoom_resolution>, <unit>), e.g., (1000, ‘meter’)

  • buffer (int, optional) – Buffer around the bbox or geom area of interest in pixels. By default 0.

  • handle_nodata (NoDataStrategy, optional) – What to do if no data can be found.

  • align (float, optional) – Resolution to align the bounding box, by default None

  • variables (str or list of str, optional.) – Names of RasterDataset variables to return. By default all dataset variables are returned.

  • time_tuple (tuple of str, datetime, optional) – Start and end date of period of interest. By default the entire time period of the dataset is returned.

  • single_var_as_array (bool, optional) – If True, return a DataArray if the dataset consists of a single variable. If False, always return a Dataset. By default True.

  • provider (str, optional) – Data source provider. If None (default) the last added provider is used.

  • version (str, optional) – Data source version. If None (default) the newest version is used.

  • **kwargs – Additional keyword arguments that are passed to the RasterDatasetAdapter function. Only used if data_like is a path to a raster file.

Returns:

obj – RasterDataset. If no data is found and handle_nodata is set to IGNORE None will be returned. if it is set to RAISE and exception will be raised in that situation

Return type:

xarray.Dataset or xarray.DataArray