hydromt.data_adapter.RasterDatasetAdapter#

class hydromt.data_adapter.RasterDatasetAdapter(path: str | Path, driver: str | None = None, filesystem: str | None = None, crs: int | str | dict | None = None, nodata: dict | float | int | None = None, rename: dict | None = None, unit_mult: dict | None = None, unit_add: dict | None = None, meta: dict | None = None, attrs: dict | None = None, extent: dict | None = None, driver_kwargs: dict | None = None, storage_options: dict | None = None, zoom_levels: dict | None = None, name: str = '', catalog_name: str = '', provider: str | None = None, version: str | None = None, **kwargs)[source]#

Implementation for the RasterDatasetAdapter.

Initiate data adapter for geospatial raster data.

This object contains all properties required to read supported raster files into a single unified RasterDataset, i.e. xarray.Dataset with geospatial attributes. In addition it keeps meta data to be able to reproduce which data is used.

Parameters:
  • path (str, Path) – Path to data source. If the dataset consists of multiple files, the path may contain {variable}, {year}, {month} placeholders as well as path search pattern using a * wildcard.

  • driver ({'raster', 'netcdf', 'zarr', 'raster_tindex'}, optional) – Driver to read files with, for ‘raster’ open_mfraster(), for ‘netcdf’ xarray.open_mfdataset(), and for ‘zarr’ xarray.open_zarr() By default the driver is inferred from the file extension and falls back to ‘raster’ if unknown.

  • filesystem (str, optional) – Filesystem where the data is stored (local, cloud, http etc.). If None (default) the filesystem is inferred from the path. See fsspec.registry.known_implementations() for all options.

  • crs (int, dict, or str, optional) – Coordinate Reference System. Accepts EPSG codes (int or str); proj (str or dict) or wkt (str). Only used if the data has no native CRS.

  • nodata (float, int, optional) – Missing value number. Only used if the data has no native missing value. Nodata values can be differentiated between variables using a dictionary.

  • rename (dict, optional) – Mapping of native data source variable to output source variable name as required by hydroMT.

  • unit_mult (dict, optional) – Scaling multiplication and addition to change to map from the native data unit to the output data unit as required by hydroMT.

  • unit_add (dict, optional) – Scaling multiplication and addition to change to map from the native data unit to the output data unit as required by hydroMT.

  • meta (dict, optional) – Metadata information of dataset, prefably containing the following keys: - ‘source_version’ - ‘source_url’ - ‘source_license’ - ‘paper_ref’ - ‘paper_doi’ - ‘category’

  • placeholders (dict, optional) – Placeholders to expand yaml entry to multiple entries (name and path) based on placeholder values

  • attrs (dict, optional) – Additional attributes relating to data variables. For instance unit or long name of the variable.

  • extent (Extent(typed dict), Optional) – Dictionary describing the spatial and time range the dataset covers. should be of the form: - “bbox”: [xmin, ymin, xmax, ymax], - “time_range”: [start_datetime, end_datetime], data, and time_range should be inclusive on both sides.

  • driver_kwargs – Additional key-word arguments passed to the driver.

  • dict – Additional key-word arguments passed to the driver.

  • optional – Additional key-word arguments passed to the driver.

  • storage_options (dict, optional) – Additional key-word arguments passed to the fsspec FileSystem object.

  • zoomlevels (dict, optional) – Dictionary with zoom levels and associated resolution in the unit of the data CRS.

  • name (str, optional) – Name of the dataset and catalog, optional.

  • catalog_name (str, optional) – Name of the dataset and catalog, optional.

  • provider (str, optional) – A name to identifiy the specific provider of the dataset requested. if None is provided, the last added source will be used.

  • version (str, optional) – A name to identifiy the specific version of the dataset requested. if None is provided, the last added source will be used.

__init__(path: str | Path, driver: str | None = None, filesystem: str | None = None, crs: int | str | dict | None = None, nodata: dict | float | int | None = None, rename: dict | None = None, unit_mult: dict | None = None, unit_add: dict | None = None, meta: dict | None = None, attrs: dict | None = None, extent: dict | None = None, driver_kwargs: dict | None = None, storage_options: dict | None = None, zoom_levels: dict | None = None, name: str = '', catalog_name: str = '', provider: str | None = None, version: str | None = None, **kwargs)[source]#

Initiate data adapter for geospatial raster data.

This object contains all properties required to read supported raster files into a single unified RasterDataset, i.e. xarray.Dataset with geospatial attributes. In addition it keeps meta data to be able to reproduce which data is used.

Parameters:
  • path (str, Path) – Path to data source. If the dataset consists of multiple files, the path may contain {variable}, {year}, {month} placeholders as well as path search pattern using a * wildcard.

  • driver ({'raster', 'netcdf', 'zarr', 'raster_tindex'}, optional) – Driver to read files with, for ‘raster’ open_mfraster(), for ‘netcdf’ xarray.open_mfdataset(), and for ‘zarr’ xarray.open_zarr() By default the driver is inferred from the file extension and falls back to ‘raster’ if unknown.

  • filesystem (str, optional) – Filesystem where the data is stored (local, cloud, http etc.). If None (default) the filesystem is inferred from the path. See fsspec.registry.known_implementations() for all options.

  • crs (int, dict, or str, optional) – Coordinate Reference System. Accepts EPSG codes (int or str); proj (str or dict) or wkt (str). Only used if the data has no native CRS.

  • nodata (float, int, optional) – Missing value number. Only used if the data has no native missing value. Nodata values can be differentiated between variables using a dictionary.

  • rename (dict, optional) – Mapping of native data source variable to output source variable name as required by hydroMT.

  • unit_mult (dict, optional) – Scaling multiplication and addition to change to map from the native data unit to the output data unit as required by hydroMT.

  • unit_add (dict, optional) – Scaling multiplication and addition to change to map from the native data unit to the output data unit as required by hydroMT.

  • meta (dict, optional) – Metadata information of dataset, prefably containing the following keys: - ‘source_version’ - ‘source_url’ - ‘source_license’ - ‘paper_ref’ - ‘paper_doi’ - ‘category’

  • placeholders (dict, optional) – Placeholders to expand yaml entry to multiple entries (name and path) based on placeholder values

  • attrs (dict, optional) – Additional attributes relating to data variables. For instance unit or long name of the variable.

  • extent (Extent(typed dict), Optional) – Dictionary describing the spatial and time range the dataset covers. should be of the form: - “bbox”: [xmin, ymin, xmax, ymax], - “time_range”: [start_datetime, end_datetime], data, and time_range should be inclusive on both sides.

  • driver_kwargs – Additional key-word arguments passed to the driver.

  • dict – Additional key-word arguments passed to the driver.

  • optional – Additional key-word arguments passed to the driver.

  • storage_options (dict, optional) – Additional key-word arguments passed to the fsspec FileSystem object.

  • zoomlevels (dict, optional) – Dictionary with zoom levels and associated resolution in the unit of the data CRS.

  • name (str, optional) – Name of the dataset and catalog, optional.

  • catalog_name (str, optional) – Name of the dataset and catalog, optional.

  • provider (str, optional) – A name to identifiy the specific provider of the dataset requested. if None is provided, the last added source will be used.

  • version (str, optional) – A name to identifiy the specific version of the dataset requested. if None is provided, the last added source will be used.

Methods

__init__(path[, driver, filesystem, crs, ...])

Initiate data adapter for geospatial raster data.

detect_bbox([ds])

Detect the bounding box and crs of the dataset.

detect_time_range([ds])

Detect the temporal range of the dataset.

get_bbox([detect])

Return the bounding box and espg code of the dataset.

get_data([bbox, geom, buffer, zoom_level, ...])

Return a clipped, sliced and unified RasterDataset.

get_time_range([detect])

Detect the time range of the dataset.

mark_as_used()

Mark the data adapter as used.

summary()

Return a dictionary summary of the data adapter.

to_dict()

Return a dictionary view of the data source.

to_file(data_root, data_name[, bbox, ...])

Save a data slice to file.

to_stac_catalog([on_error])

Convert a rasterdataset into a STAC Catalog representation.

Attributes

data_type

Return the datatype of the addapter.

fs

Return the filesystem object .