hydromt.data_catalog.adapters.RasterDatasetAdapter.transform#

RasterDatasetAdapter.transform(ds: Dataset, metadata: SourceMetadata, *, mask: GeoDataFrame | GeoSeries | None = None, align: bool | None = None, variables: str | List[str] | None = None, time_range: Annotated[Tuple[datetime, datetime], BeforeValidator(func=_time_range_from_str, json_schema_input_type=PydanticUndefined), AfterValidator(func=_time_range_validate)] | None = None, handle_nodata: NoDataStrategy = NoDataStrategy.RAISE, single_var_as_array: bool = True) Dataset | DataArray | None[source]#

Filter and harmonize the input RasterDataset.

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

  • metadata (SourceMetadata) – source metadata

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

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

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

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

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

Returns:

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

Return type:

Optional[xr.Dataset]

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