hydromt.data_catalog.DataCatalog.get_geodataset#

DataCatalog.get_geodataset(data_like: str | ~hydromt._typing.type_def.SourceSpecDict | ~pathlib.Path | ~xarray.core.dataset.Dataset | ~xarray.core.dataarray.DataArray | ~hydromt.data_catalog.sources.geodataset.GeoDatasetSource, bbox: ~typing.Annotated[~typing.Tuple[float, float, float, float], <function _validate_bbox at 0x7f35298edd00>] | None = None, geom: ~geopandas.geodataframe.GeoDataFrame | None = None, buffer: float | int = 0, handle_nodata: ~hydromt._typing.error.NoDataStrategy = NoDataStrategy.RAISE, predicate: str = 'intersects', variables: ~typing.List[str] | None = None, time_range: ~typing.Tuple[str, str] | ~typing.Tuple[~datetime.datetime, ~datetime.datetime] | None = None, single_var_as_array: bool = True, provider: str | None = None, version: str | None = None, **kwargs) Dataset[source]#

Return a clipped, sliced and unified GeoDataset.

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 Dataset.

Parameters:
  • data_like (Union[ str, SourceSpecDict, Path, xr.Dataset, xr.DataArray, GeoDatasetSource ]) – Data catalog key, path to GeoDataset file, a GeoDatasetSource object, or GeoDataset 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

  • 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

  • predicate (str, optional) – If predicate is provided, the GeoDataSet is filtered by testing the predicate function against each item. Requires bbox or mask. options are: {‘intersects’, ‘within’, ‘contains’, ‘overlaps’, ‘crosses’, ‘touches’}, by default ‘intersects’

  • variables (Optional[List], optional) – Names of GeoDataset 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 GeoDatasetSource construction

Returns:

a clipped, sliced and unified GeoDataset

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