hydromt.data_catalog.drivers.RasterioDriver#

pydantic model hydromt.data_catalog.drivers.RasterioDriver[source]#

Driver for RasterDataset using the rasterio library: rasterio.

Supports reading and writing raster files using rasterio.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

name: ClassVar[str] = 'rasterio'#
SUPPORTED_EXTENSIONS: ClassVar[set[str]] = {'.asc', '.bag', '.bil', '.blx', '.bmp', '.bt', '.byn', '.cal', '.ct1', '.cub', '.dat', '.dem', '.dt0', '.dt1', '.dt2', '.err', '.ers', '.gen', '.gif', '.gpkg', '.gpkg.zip', '.grb', '.grb2', '.grd', '.grib2', '.gsb', '.gtx', '.gvb', '.hdr', '.hf2', '.hgt', '.img', '.j2k', '.jp2', '.jpeg', '.jpg', '.kml', '.kmz', '.kro', '.lbl', '.lcp', '.map', '.mbtiles', '.mpl', '.mpr', '.mrf', '.ntf', '.pdf', '.pgm', '.pix', '.png', '.pnm', '.ppm', '.rda', '.rgb', '.rst', '.rsw', '.sdat', '.sg-grd-z', '.sigdem', '.sqlite', '.ter', '.tif', '.tiff', '.vrt', '.webp', '.xml', '.xpm', '.xyz'}#

“Set of supported file extensions for this driver.

field options: RasterioOptions [Optional]#
read(uris: list[str], *, handle_nodata: NoDataStrategy = NoDataStrategy.RAISE, mask: GeoDataFrame | GeoSeries | None = None, variables: str | List[str] | None = None, zoom: int | Tuple[float, str] | None = None, chunks: dict[str, Any] | None = None, metadata: SourceMetadata | None = None) Dataset[source]#

Read raster data using the rasterio library.

Supports reading single or multiple raster files (optionally mosaicked), applying spatial masks, caching VRT tiles, and reading overviews at different zoom levels. Returns an xarray Dataset constructed from raster bands.

Parameters:
  • uris (list[str]) – List of raster file URIs to read.

  • handle_nodata (NoDataStrategy, optional) – Strategy for handling missing or empty data. Default is NoDataStrategy.RAISE.

  • mask (Geom | None, optional) – Geometry used to mask or clip the raster data. Default is None.

  • variables (Variables | None, optional) – List of variables or band names to read. Default is None.

  • zoom (Zoom | None, optional) – Requested zoom level or resolution. Used to determine the appropriate overview level. Default is None.

  • chunks (dict[str, Any] | None, optional) – Dask chunking configuration for lazy loading. Default is None.

  • metadata (SourceMetadata | None, optional) – Optional metadata describing CRS, nodata, and overview levels. Default is None.

Returns:

The loaded raster dataset as an xarray Dataset.

Return type:

xr.Dataset

Raises:
write(path: Path | str, data: Dataset, *, write_kwargs: dict[str, Any] | None = None) Path[source]#

Write a RasterDataset to disk using the rasterio library.

This method is not implemented in this driver. Concrete implementations must provide a way to write raster datasets to supported formats.

Parameters:
  • path (Path | str) – Destination path for the raster dataset.

  • data (xr.Dataset) – The xarray Dataset to write.

  • write_kwargs (dict[str, Any] | None, optional) – Additional keyword arguments for writing. Default is None.

Raises:

NotImplementedError – Always raised because writing is not supported in this driver.