hydromt.data_catalog.adapters.GeoDatasetAdapter.transform#

GeoDatasetAdapter.transform(ds: Dataset, metadata: SourceMetadata, *, mask: GeoDataFrame | GeoSeries | None = None, predicate: Literal['intersects', 'within', 'contains', 'overlaps', 'crosses', 'touches'] = 'intersects', variables: str | List[str] | None = None, time_range: Annotated[Tuple[datetime, datetime], BeforeValidator(func=_time_range_from_str), AfterValidator(func=_time_range_validate)] | None = None, single_var_as_array: bool = True, handle_nodata: NoDataStrategy = NoDataStrategy.RAISE) Dataset | DataArray | None[source]#

Return a clipped, sliced and harmonized RasterDataset.

Parameters:
  • ds (xr.Dataset) – input GeoDataset

  • metadata (SourceMetadata) – source metadata

  • mask (Optional[gpd.GeoDataFrame], optional) – mask to filter by geometry, by default None

  • predicate (str, optional) – predicate to use for the mask filter, by default “intersects”

  • variables (Optional[List[str]], optional) – variable filter, by default None

  • time_range (Optional[TimeRange], optional) – filter start and end times, by default None

  • single_var_as_array (bool, optional) – whether to return a xr.DataArray if only a single variable is present, by default True

  • handle_nodata (NoDataStrategy, optional) – how to handle no data being present in the result, by default NoDataStrategy.RAISE

Returns:

The filtered and harmonized GeoDataset, or None if no data was available

Return type:

Optional[Union[xr.Dataset, xr.DataArray]]

Raises:
  • ValueError – if not all variables are found in the data

  • NoDataException – if no data in left after slicing and handle_nodata is NoDataStrategy.RAISE