Skip to content

rio_tiler.experimental.zarr

rio_tiler.experimental.zarr

rio_tiler.experimental.zarr reader: rio-tiler Async reader built on top of zarr-python.

ArrayMetadata

Bases: TypedDict

Array Metadata.

GeoZarrInfo

Bases: Bounds

GeoZarr Info.

GeoZarrReader

Bases: AsyncBaseReader

Rio-tiler GeoZarr Reader.

A pure zarr-python async reader that accepts a zarr AsyncGroup (GeoZarr)

Attributes:

  • input (AsyncGroup) –

    zarr AsyncGroup

  • tms (TileMatrixSet) –

    TileMatrixSet for tile operations.

maxzoom property

maxzoom: int

Return dataset maxzoom.

minzoom property

minzoom: int

Return dataset minzoom.

__aenter__ async

__aenter__()

Support using with Context Managers.

__aexit__ async

__aexit__(exc_type, exc_value, traceback)

Support using with Context Managers.

__attrs_post_init__

__attrs_post_init__() -> None

Post init: derive height, width, count from array shape.

feature async

feature(shape: dict, *, variables: Sequence[str] | str, dst_crs: CRS | None = None, shape_crs: CRS = WGS84_CRS, expression: str | None = None, max_size: int | None = None, height: int | None = None, width: int | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', **kwargs: Any) -> ImageData

Read a Dataset for a GeoJSON feature.

Parameters:

  • shape (dict) –

    Valid GeoJSON feature.

Returns:

  • ImageData

    rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.

get_bounds async

get_bounds(*, variables: Sequence[str] | str, crs: CRS = WGS84_CRS) -> BBox

Get BBox for variables.

get_group_metadata async

get_group_metadata(group: str) -> GroupMetadata

Find arrays in a Zarr store and extract spatial metadata.

get_maxzoom async

get_maxzoom(*, variables: Sequence[str] | str) -> int

Get maxzoom for variables.

get_minzoom async

get_minzoom(*, variables: Sequence[str] | str) -> int

Get minzoom for variables.

info async

info() -> GeoZarrInfo

Return Dataset's info.

Returns:

list_variables async

list_variables() -> list[str]

List variables in the Zarr store.

parse_variable

parse_variable(variable: str) -> tuple[str, str, Any | None]

Parse variable name into group, variable and options.

part async

part(bbox: BBox, *, variables: Sequence[str] | str, expression: str | None = None, dst_crs: CRS | None = None, bounds_crs: CRS = WGS84_CRS, max_size: int | None = None, height: int | None = None, width: int | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', **kwargs: Any) -> ImageData

Read a Part of a Dataset.

Parameters:

  • bbox (tuple) –

    Output bounds (left, bottom, right, top) in target crs.

  • variables (list of str or str) –

    list of variables to return value for.

Returns:

  • ImageData

    rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.

point async

point(lon: float, lat: float, *, variables: Sequence[str] | str, expression: str | None = None, coord_crs: CRS = WGS84_CRS, nodata: NoData | None = None, **kwargs: Any) -> PointData

Read a value from a Dataset.

Parameters:

  • lon (float) –

    Longitude.

  • lat (float) –

    Latitude.

Returns:

  • PointData

    rio_tiler.models.PointData: PointData instance with data, mask and spatial info.

preview async

preview(*, variables: Sequence[str] | str, expression: str | None = None, dst_crs: CRS | None = None, max_size: int | None = 1024, height: int | None = None, width: int | None = None, nodata: NoData | None = None, resampling_method: RIOResampling = 'nearest', reproject_method: WarpResampling = 'nearest', **kwargs: Any) -> ImageData

Read a preview of a Dataset.

Returns:

  • ImageData

    rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.

select_variable

select_variable(variable_metadata: list[ArrayMetadata], *, bounds: BBox | None = None, height: int | None = None, width: int | None = None, max_size: int | None = None, dst_crs: CRS | None = None) -> ArrayMetadata

Get DataArray from xarray Dataset.

statistics async

statistics(*, variables: Sequence[str] | str, expression: str | None = None, categorical: bool = False, categories: list[float] | None = None, percentiles: list[int] | None = None, hist_options: dict | None = None, max_size: int | None = 1024, nodata: NoData | None = None, **kwargs: Any) -> dict[str, BandStatistics]

Return bands statistics from a dataset.

Parameters:

  • variables (list of str or str) –

    list of variables to return value for. Defaults to all variables.

  • categorical (bool, default: False ) –

    treat input data as categorical data. Defaults to False.

  • categories (list of numbers, default: None ) –

    list of categories to return value for.

  • percentiles (list of numbers, default: None ) –

    list of percentile values to calculate. Defaults to [2, 98].

  • hist_options (dict, default: None ) –

    Options to forward to numpy.histogram function.

  • max_size (int, default: 1024 ) –

    Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024.

  • expression (str, default: None ) –

    rio-tiler expression (e.g. b1/b2+b3).

  • kwargs (optional, default: {} ) –

    Options to forward to self.preview.

Returns:

  • dict[str, BandStatistics]

    dict[str, rio_tiler.models.BandStatistics]: bands statistics.

tile async

tile(tile_x: int, tile_y: int, tile_z: int, *, variables: Sequence[str] | str, expression: str | None = None, tilesize: int | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', **kwargs: Any) -> ImageData

Read a Map tile from the Dataset.

Parameters:

  • tile_x (int) –

    Tile's horizontal index.

  • tile_y (int) –

    Tile's vertical index.

  • tile_z (int) –

    Tile's zoom level index.

Returns:

  • ImageData

    rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.

GroupMetadata

Bases: TypedDict

Group Metadata.

Reader

Bases: AsyncBaseReader

Rio-tiler Zarr.AsyncArray Reader.

A pure zarr-python async reader that accepts a zarr AsyncArray plus geospatial metadata (transform, crs) as input.

Attributes:

  • input (AsyncArray) –

    zarr AsyncArray (2D or 3D with bands-first layout).

  • crs (CRS | None) –

    Coordinate reference system.

  • transform (Affine | None) –

    Affine transform.

  • tms (TileMatrixSet) –

    TileMatrixSet for tile operations.

Note

For 3D arrays, expects bands-first layout (bands, height, width). For 2D arrays, treats as single-band (height, width).

band_descriptions property

band_descriptions: list[str]

Return list of band descriptions in DataArray.

Bands are all dimensions not defined as spatial dims by rioxarray.

maxzoom property

maxzoom

Return dataset maxzoom.

minzoom property

minzoom

Return dataset minzoom.

NOTE: because a zarr.Array doesn't have overviews, minzoom is the same as maxzoom.

__aenter__ async

__aenter__()

Support using with Context Managers.

__aexit__ async

__aexit__(exc_type, exc_value, traceback)

Support using with Context Managers.

__attrs_post_init__

__attrs_post_init__() -> None

Post init: derive height, width, count from array shape.

_read async

_read(indexes: Sequence[int] | None = None, row_slice: slice | None = None, col_slice: slice | None = None, nodata: NoData | None = None) -> ImageData

Read data from zarr AsyncArray.

Parameters:

  • indexes (Sequence[int] | None, default: None ) –

    Band indexes (1-based). If None, reads all bands.

  • row_slice (slice | None, default: None ) –

    Row slice for windowed read.

  • col_slice (slice | None, default: None ) –

    Column slice for windowed read.

  • nodata (int or float, default: None ) –

    Overwrite dataset internal nodata value.

Returns:

  • ImageData ( ImageData ) –

    Image data with mask and spatial info.

feature async

feature(shape: dict, dst_crs: CRS | None = None, shape_crs: CRS = WGS84_CRS, indexes: Indexes | None = None, expression: str | None = None, max_size: int | None = None, height: int | None = None, width: int | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', **kwargs: Any) -> ImageData

Read a Dataset for a GeoJSON feature.

Parameters:

  • shape (dict) –

    Valid GeoJSON feature.

  • dst_crs (CRS, default: None ) –

    Overwrite target coordinate reference system.

  • shape_crs (CRS, default: WGS84_CRS ) –

    Input geojson coordinate reference system. Defaults to epsg:4326.

  • indexes (sequence of int or int, default: None ) –

    Band indexes.

  • expression (str, default: None ) –

    rio-tiler expression (e.g. b1/b2+b3).

  • max_size (int, default: None ) –

    Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio.

  • height (int, default: None ) –

    Output height of the array.

  • width (int, default: None ) –

    Output width of the array.

  • nodata (int or float, default: None ) –

    Overwrite dataset internal nodata value.

  • reproject_method (WarpResampling, default: 'nearest' ) –

    WarpKernel resampling algorithm. Defaults to nearest.

Returns:

  • ImageData

    rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.

info async

info() -> Info

Return Dataset's info.

Returns:

  • Info

    rio_tiler.models.Info: Dataset info.

part async

part(bbox: BBox, dst_crs: CRS | None = None, bounds_crs: CRS = WGS84_CRS, indexes: Indexes | None = None, expression: str | None = None, max_size: int | None = None, height: int | None = None, width: int | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', resampling_method: RIOResampling = 'nearest', **kwargs: Any) -> ImageData

Read a Part of a Dataset.

Parameters:

  • bbox (tuple) –

    Output bounds (left, bottom, right, top) in target crs.

  • dst_crs (CRS, default: None ) –

    Target coordinate reference system. Defaults to bounds_crs.

  • bounds_crs (CRS, default: WGS84_CRS ) –

    CRS of the input bounds. Defaults to WGS84.

  • indexes (sequence of int or int, default: None ) –

    Band indexes.

  • expression (str, default: None ) –

    rio-tiler expression (e.g. b1/b2+b3).

  • max_size (int, default: None ) –

    Limit the size of the longest dimension.

  • height (int, default: None ) –

    Output height of the array.

  • width (int, default: None ) –

    Output width of the array.

  • nodata (int or float, default: None ) –

    Overwrite dataset internal nodata value.

  • reproject_method (str, default: 'nearest' ) –

    Resampling method for reprojection. Defaults to "nearest".

Returns:

  • ImageData

    rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.

point async

point(lon: float, lat: float, coord_crs: CRS = WGS84_CRS, indexes: Indexes | None = None, expression: str | None = None, nodata: NoData | None = None, **kwargs: Any) -> PointData

Read a value from a Dataset.

Parameters:

  • lon (float) –

    Longitude.

  • lat (float) –

    Latitude.

  • coord_crs (CRS, default: WGS84_CRS ) –

    Coordinate Reference System of the input coords. Defaults to epsg:4326.

  • indexes (sequence of int or int, default: None ) –

    Band indexes.

  • expression (str | None, default: None ) –

    (str, optional): Expression to apply on the pixel values. Defaults to None.

  • nodata (NoData | None, default: None ) –

    (int or float, optional): Overwrite dataset internal nodata value. Defaults to None.

Returns:

  • PointData ( PointData ) –

    Pixel value per bands/assets.

preview async

preview(indexes: Indexes | None = None, expression: str | None = None, dst_crs: CRS | None = None, max_size: int | None = 1024, height: int | None = None, width: int | None = None, nodata: NoData | None = None, resampling_method: RIOResampling = 'nearest', reproject_method: WarpResampling = 'nearest', **kwargs: Any) -> ImageData

Read a preview of a Dataset.

Parameters:

  • indexes (sequence of int or int, default: None ) –

    Band indexes.

  • expression (str, default: None ) –

    rio-tiler expression (e.g. b1/b2+b3).

  • dst_crs (CRS, default: None ) –

    Target coordinate reference system. Defaults to None (same as input).

  • max_size (int, default: 1024 ) –

    Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024.

  • height (int, default: None ) –

    Output height of the array.

  • width (int, default: None ) –

    Output width of the array.

  • nodata (int or float, default: None ) –

    Overwrite dataset internal nodata value.

  • resampling_method (str, default: 'nearest' ) –

    GDAL Resampling method to use when resizing. Defaults to "nearest".

  • reproject_method (str, default: 'nearest' ) –

    GDAL Resampling method to use when reprojecting. Defaults to "nearest".

Returns:

  • ImageData

    rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.

statistics async

statistics(categorical: bool = False, categories: list[float] | None = None, percentiles: list[int] | None = None, hist_options: dict | None = None, indexes: Indexes | None = None, expression: str | None = None, nodata: NoData | None = None, **kwargs: Any) -> dict[str, BandStatistics]

Return bands statistics from a dataset.

Parameters:

  • categorical (bool, default: False ) –

    treat input data as categorical data. Defaults to False.

  • categories (list of numbers, default: None ) –

    list of categories to return value for.

  • percentiles (list of numbers, default: None ) –

    list of percentile values to calculate. Defaults to [2, 98].

  • hist_options (dict, default: None ) –

    Options to forward to numpy.histogram function.

  • max_size (int) –

    Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024.

  • indexes (int or sequence of int, default: None ) –

    Band indexes.

  • expression (str, default: None ) –

    rio-tiler expression (e.g. b1/b2+b3).

  • kwargs (optional, default: {} ) –

    Options to forward to self.preview.

Returns:

  • dict[str, BandStatistics]

    dict[str, rio_tiler.models.BandStatistics]: bands statistics.

tile async

tile(tile_x: int, tile_y: int, tile_z: int, tilesize: int | None = None, indexes: Indexes | None = None, expression: str | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', **kwargs: Any) -> ImageData

Read a Map tile from the Dataset.

Parameters:

  • tile_x (int) –

    Tile's horizontal index.

  • tile_y (int) –

    Tile's vertical index.

  • tile_z (int) –

    Tile's zoom level index.

  • tilesize (int, default: None ) –

    Output tile size. Defaults to TMS tilesize.

  • indexes (sequence of int or int, default: None ) –

    Band indexes.

  • expression (str, default: None ) –

    rio-tiler expression (e.g. b1/b2+b3).

  • nodata (int or float, default: None ) –

    Overwrite dataset internal nodata value.

  • reproject_method (WarpResampling, default: 'nearest' ) –

    WarpKernel resampling algorithm. Defaults to nearest.

Returns:

  • ImageData

    rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.

_get_proj_crs

_get_proj_crs(attributes: dict) -> CRS

Get CRS defined by PROJ conventions.

_get_zoom

_get_zoom(tms: TileMatrixSet, crs: CRS, width: int, height: int, bounds: BBox) -> int

Get MaxZoom for a Group.

calculate_output_transform

calculate_output_transform(crs: CRS, bounds: BBox, height: int, width: int, out_crs: CRS, *, out_bounds: BBox | None = None, out_max_size: int | None = None, out_height: int | None = None, out_width: int | None = None) -> Affine

Calculate Reprojected Dataset transform.

get_multiscale_level

get_multiscale_level(variable_metadata: list[ArrayMetadata], target_res: float, zoom_level_strategy: Literal['AUTO', 'LOWER', 'UPPER'] = 'AUTO') -> ArrayMetadata

Return the multiscale level corresponding to the desired resolution.

get_target_resolution

get_target_resolution(*, input_crs: CRS, output_crs: CRS, input_height: int, input_width: int, input_transform: Affine, output_bounds: BBox | None = None, output_max_size: int | None = None, output_height: int | None = None, output_width: int | None = None) -> float

Get Target Resolution.