rio_tiler.experimental.zarr
rio_tiler.experimental.zarr ¶
rio_tiler.experimental.zarr reader: rio-tiler Async reader built on top of zarr-python.
ZARR_MAX_CHILDREN_DEPTH
module-attribute
¶
ZARR_MAX_CHILDREN_DEPTH: int = int(os.environ.get('RIO_TILER_ZARR_MAX_CHILDREN_DEPTH', 10))
The maximum number of levels of the hierarchy to include within one Zarr Store. Set
RIO_TILER_ZARR_MAX_CHILDREN_DEPTH=-1 to include all nodes, and some positive integer
to consider children within that many levels of the root Group.
ZARR_METADATA_CACHE_MAXSIZE
module-attribute
¶
ZARR_METADATA_CACHE_MAXSIZE: int = int(os.environ.get('RIO_TILER_ZARR_METADATA_CACHE_MAXSIZE', 512))
Maximum number of Zarr groups metadata to keep in cache (shared by all Group readers).
ZARR_METADATA_CACHE_TTL
module-attribute
¶
ZARR_METADATA_CACHE_TTL: int = int(os.environ.get('RIO_TILER_ZARR_METADATA_CACHE_TTL', 300))
Time (in seconds) a Zarr group metadata stays in cache. Set 0 to disable expiration.
ArrayMetadata ¶
Bases: TypedDict
Array Metadata.
ArrayMixin ¶
Bases: SpatialMixin
Shared attributes/methods for Async/Sync Array Readers.
_coordinates
cached
property
¶
_coordinates: dict[str, tuple[ndarray, Callable[[ndarray], list[Any]]]]
Return coordinate values and labels getter for each non-spatial dimension.
- values: derived from the
coordinates(inline or interval), used for selection. Default to the array positions (0, 1, ..., n - 1) when not available. - labels getter: return the labels for an array of positions. Labels are the inline
values as defined in the coordinates, formatted interval values or
{dim}{position + 1}(e.gtime1) when coordinates are not available.
NOTE: labels are created only for the requested positions (dimensions can be large).
coordinate_values
property
¶
coordinate_values: dict[str, ndarray]
Return coordinate values (used for selection) for each non-spatial dimension.
minzoom
property
¶
minzoom
Return dataset minzoom.
NOTE: because a zarr.Array doesn't have overviews, minzoom is the same as maxzoom.
non_spatial_dims
cached
property
¶
non_spatial_dims: list[str]
Return the non-spatial dimensions (in array order).
__attrs_post_init__ ¶
__attrs_post_init__() -> None
Post init: derive height, width, count from array shape.
_get_labels ¶
_get_labels(dim: str, idx: int | ndarray | slice | None = None) -> list[Any]
Return labels for a positional selection on a non-spatial dimension (all labels when idx is None).
_get_non_spatial_selection ¶
_get_non_spatial_selection(sel: Sequence[Selector] | None = None) -> dict[str, int | ndarray | slice]
Convert label based selection to positional selection for non-spatial dimensions.
Parameters:
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]).
Returns:
-
dict(dict[str, int | ndarray | slice]) –positional selection per (non-spatial) dimension.
ArrayReader ¶
Bases: BaseReader, ArrayMixin
Rio-tiler Zarr.Array Reader.
A pure zarr-python sync reader that accepts a zarr.Array plus geospatial metadata (transform, crs) as input.
Attributes:
-
input(Array) –zarr Array (2D or 3D with bands-first layout).
-
crs(CRS) –Coordinate reference system.
-
transform(Affine) –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).
_read ¶
_read(*, y_slice: slice | None = None, x_slice: slice | None = None, sel: Sequence[Selector] | None = None, nodata: NoData | None = None) -> ImageData
Read data from zarr Array.
Parameters:
-
y_slice(slice | None, default:None) –index along the Y-axis dimension (named in self.spatial_dim[0]).
-
x_slice(slice | None, default:None) –index along the X-axis dimension (named in self.spatial_dim[1])
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions.
-
nodata(int or float, default:None) –Overwrite dataset internal nodata value.
Returns:
-
ImageData(ImageData) –Image data with shape (*non-spatial dimensions, height, width), mask and spatial info.
feature ¶
feature(shape: dict, dst_crs: CRS | None = None, shape_crs: CRS = WGS84_CRS, sel: Sequence[Selector] | 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 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. -
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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. -
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
part ¶
part(bbox: BBox, dst_crs: CRS | None = None, bounds_crs: CRS = WGS84_CRS, sel: Sequence[Selector] | 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.
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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".
-
resampling_method(str, default:'nearest') –Resampling method for array read. Defaults to "nearest".
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
point ¶
point(lon: float, lat: float, coord_crs: CRS = WGS84_CRS, sel: Sequence[Selector] | 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. -
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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 ¶
preview(sel: Sequence[Selector] | 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:
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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 ¶
statistics(categorical: bool = False, categories: list[float] | None = None, percentiles: list[int] | None = None, hist_options: dict | None = None, sel: Sequence[Selector] | 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.
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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 ¶
tile(tile_x: int, tile_y: int, tile_z: int, tilesize: int | None = None, sel: Sequence[Selector] | None = None, expression: str | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', resampling_method: RIOResampling = '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.
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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. -
resampling_method(str, default:'nearest') –Resampling method for array read. Defaults to "nearest".
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
AsyncArrayReader ¶
Bases: AsyncBaseReader, ArrayMixin
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) –Coordinate reference system.
-
transform(Affine) –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).
_read
async
¶
_read(*, y_slice: slice | None = None, x_slice: slice | None = None, sel: Sequence[Selector] | None = None, nodata: NoData | None = None) -> ImageData
Read data from zarr AsyncArray.
Parameters:
-
y_slice(slice | None, default:None) –index along the Y-axis dimension (named in self.spatial_dim[0]).
-
x_slice(slice | None, default:None) –index along the X-axis dimension (named in self.spatial_dim[1])
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions.
-
nodata(int or float, default:None) –Overwrite dataset internal nodata value.
Returns:
-
ImageData(ImageData) –Image data with shape (*non-spatial dimensions, height, width), mask and spatial info.
feature
async
¶
feature(shape: dict, dst_crs: CRS | None = None, shape_crs: CRS = WGS84_CRS, sel: Sequence[Selector] | 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 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. -
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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.
part
async
¶
part(bbox: BBox, dst_crs: CRS | None = None, bounds_crs: CRS = WGS84_CRS, sel: Sequence[Selector] | 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.
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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".
-
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. 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, sel: Sequence[Selector] | 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. -
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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(sel: Sequence[Selector] | 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:
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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, sel: Sequence[Selector] | 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.
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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, sel: Sequence[Selector] | None = None, expression: str | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', resampling_method: RIOResampling = '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.
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions (e.g
[{"dimension": "time", "values": "2025-01-01", "method": "nearest"}, {"dimension": "z", "values": [10, 20]}]). Dimensions without coordinates use positions. -
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. -
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
AsyncGroupReader ¶
Bases: AsyncBaseReader, GroupMixin
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.
feature
async
¶
feature(shape: dict, *, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | None = None, dst_crs: CRS | None = None, shape_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', resampling_method: RIOResampling = 'nearest', **kwargs: Any) -> ImageData
Read a Dataset for a GeoJSON feature.
Parameters:
-
shape(dict) –Valid GeoJSON feature.
-
variables(list of str or str) –list of variables to return value for.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions, applied to all the variables (e.g
[{"dimension": "time", "values": "2025-01-01"}]). -
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
dst_crs(CRS, default:None) –Target coordinate reference system. Defaults to shape_crs.
-
shape_crs(CRS, default:WGS84_CRS) –Input geojson coordinate reference system. Defaults to
epsg:4326. -
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".
-
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. Defaults to
nearest.
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 | None = None) -> GroupMetadata
Find arrays in a Zarr Group and extract 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
part
async
¶
part(bbox: BBox, *, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | 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', 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.
-
variables(list of str or str) –list of variables to return value for.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions, applied to all the variables (e.g
[{"dimension": "time", "values": "2025-01-01"}]). -
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
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.
-
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".
-
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. 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, *, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | 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.
-
variables(list of str or str) –list of variables to return value for.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions, applied to all the variables (e.g
[{"dimension": "time", "values": "2025-01-01"}]). -
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
coord_crs(CRS, default:WGS84_CRS) –Coordinate Reference System of the input coords. Defaults to
epsg:4326. -
nodata(NoData | None, default:None) –(int or float, optional): Overwrite dataset internal nodata value. Defaults to
None.
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, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | None = None, dst_crs: CRS | None = None, max_size: int | None = 1024, 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 preview of a Dataset.
Parameters:
-
variables(list of str or str) –list of variables to return value for.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions, applied to all the variables (e.g
[{"dimension": "time", "values": "2025-01-01"}]). -
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
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.
-
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".
-
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
statistics
async
¶
statistics(*, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | 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.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions.
-
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
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, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | None = None, tilesize: int | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', resampling_method: RIOResampling = '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.
-
variables(Sequence[str] | str) –Variables to read from the dataset.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions.
-
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
tilesize(int, default:None) –Size of the tile in pixels. Defaults to None.
-
nodata(NoData, default:None) –Nodata value to use. Defaults to None.
-
reproject_method(WarpResampling, default:'nearest') –Resampling method to use for reprojection. Defaults to "nearest".
-
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
GroupMetadata ¶
Bases: TypedDict
Group Metadata.
GroupMixin ¶
Bases: SpatialMixin
Shared attributes/methods for Async/Sync Group Readers.
__attrs_post_init__ ¶
__attrs_post_init__() -> None
Post init: derive height, width, count from array shape.
parse_variable ¶
parse_variable(variable: str) -> tuple[str | None, str, Any | None]
Parse variable name into group, variable and options.
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.
GroupReader ¶
Bases: BaseReader, GroupMixin
Rio-tiler Zarr.Group Reader.
A pure zarr-python sync reader that accepts a zarr.Group (GeoZarr)
Attributes:
-
input(Group) –zarr Group
-
tms(TileMatrixSet) –TileMatrixSet for tile operations.
feature ¶
feature(shape: dict, *, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | None = None, dst_crs: CRS | None = None, shape_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', resampling_method: RIOResampling = 'nearest', **kwargs: Any) -> ImageData
Read a Dataset for a GeoJSON feature.
Parameters:
-
shape(dict) –Valid GeoJSON feature.
-
variables(list of str or str) –list of variables to return value for.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions, applied to all the variables (e.g
[{"dimension": "time", "values": "2025-01-01"}]). -
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
dst_crs(CRS, default:None) –Target coordinate reference system. Defaults to shape_crs.
-
shape_crs(CRS, default:WGS84_CRS) –Input geojson coordinate reference system. Defaults to
epsg:4326. -
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".
-
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
get_bounds ¶
get_bounds(*, variables: Sequence[str] | str, crs: CRS = WGS84_CRS) -> BBox
Get BBox for variables.
get_group_metadata ¶
get_group_metadata(group: str | None = None) -> GroupMetadata
Find arrays in a Zarr Group and extract metadata.
info ¶
info() -> GeoZarrInfo
part ¶
part(bbox: BBox, *, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | 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.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions, applied to all the variables (e.g
[{"dimension": "time", "values": "2025-01-01"}]). -
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
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.
-
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".
-
resampling_method(RIOResampling) –Resampling method for array read. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
point ¶
point(lon: float, lat: float, *, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | 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.
-
variables(list of str or str) –list of variables to return value for.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions, applied to all the variables (e.g
[{"dimension": "time", "values": "2025-01-01"}]). -
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
coord_crs(CRS, default:WGS84_CRS) –Coordinate Reference System of the input coords. Defaults to
epsg:4326. -
nodata(NoData | None, default:None) –(int or float, optional): Overwrite dataset internal nodata value. Defaults to
None.
Returns:
-
PointData–rio_tiler.models.PointData: PointData instance with data, mask and spatial info.
preview ¶
preview(*, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | 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:
-
variables(list of str or str) –list of variables to return value for.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions, applied to all the variables (e.g
[{"dimension": "time", "values": "2025-01-01"}]). -
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
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.
-
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".
-
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and input spatial info.
statistics ¶
statistics(*, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | 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.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions.
-
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
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 ¶
tile(tile_x: int, tile_y: int, tile_z: int, *, variables: Sequence[str] | str, expression: str | None = None, sel: Sequence[Selector] | None = None, reduce: list[tuple[str, Callable[..., MaskedArray]]] | None = None, tilesize: int | None = None, nodata: NoData | None = None, reproject_method: WarpResampling = 'nearest', resampling_method: RIOResampling = '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.
-
variables(Sequence[str] | str) –Variables to read from the dataset.
-
expression(str, default:None) –rio-tiler expression (e.g. b1/b2+b3).
-
sel(list of Selector, default:None) –label based selection for non-spatial dimensions.
-
reduce(list of tuple, default:None) –List of reduction operations to apply on the data. Each tuple should contain the name of the reduced dimension and a callable function. Defaults to None.
-
tilesize(int, default:None) –Size of the tile in pixels. Defaults to None.
-
nodata(NoData, default:None) –Nodata value to use. Defaults to None.
-
reproject_method(WarpResampling, default:'nearest') –Resampling method to use for reprojection. Defaults to "nearest".
-
resampling_method(RIOResampling, default:'nearest') –Resampling method for array read. Defaults to
nearest.
Returns:
-
ImageData–rio_tiler.models.ImageData: ImageData instance with data, mask and tile spatial info.
Selector ¶
Bases: TypedDict
Label based selection for one non-spatial dimension.
Attributes:
-
dimension(str) –non-spatial dimension name.
-
values(Any) –scalar label (the dimension is dropped), sequence of labels or slice of labels (inclusive bounds).
-
method(str) –method to use for inexact matches (nearest, pad/ffill, backfill/bfill). Defaults to exact match.
VariableMetadata ¶
Bases: TypedDict
Variable Metadata.
_coerce_label ¶
_coerce_label(label: Any, values: ndarray) -> Any
Cast a selection label to the coordinate values type.
_format_coordinate_values ¶
_format_coordinate_values(values: ndarray) -> list[Any]
Convert coordinate values to JSON friendly labels (ISO 8601 string for temporal values).
_get_coordinate_values ¶
_get_coordinate_values(coordinates: dict) -> ndarray | None
Return coordinate values from coordinates convention.
Supports for 2 types: - Inline coordinate values — short value vectors embedded directly in the metadata (for example, a 4-band spectral axis where allocating a separate array would be wasteful). - Implicit regularly spaced values — a compact start / end / step descriptor for axes that are uniformly spaced, covering both numeric domains (angles, distances, frequencies, levels) and ISO 8601 time intervals, without enumerating every value.
Returns:
-
ndarray | None–numpy.ndarray: numeric,
datetime64[ns](temporal) or string values.
_get_slices ¶
_get_slices(window: Window, height: int, width: int, pad: int = 0) -> tuple[slice, slice]
Get the Y/X slices covering a pixel window, clamped to the array bounds.
Parameters:
-
window(Window) –Pixel window (can be fractional and/or outside the array).
-
height(int) –Array height.
-
width(int) –Array width.
-
pad(int, default:0) –Number of pixels to add on each side of the window (e.g. for resampling kernels needing neighbouring pixels). Defaults to
0.
Returns:
-
tuple[slice, slice]–tuple[slice, slice]: Y (rows) and X (columns) slices.
Raises:
-
InvalidBounds–If the window does not intersect the array.
_get_zoom ¶
_get_zoom(tms: TileMatrixSet, crs: CRS, width: int, height: int, bounds: BBox) -> int
Get MaxZoom for a Group.
_sel_indexer ¶
_sel_indexer(values: ndarray, selector: Any, method: SelMethod | None = None, dim: str = '') -> int | ndarray | slice
Convert a label-based selector to a positional indexer (like xarray.DataArray.sel).
Parameters:
-
values(ndarray) –coordinate values.
-
selector(Any) –scalar label, sequence of labels or slice of labels (inclusive bounds).
-
method(str, default:None) –method to use for inexact matches (nearest, pad/ffill, backfill/bfill).
-
dim(str, default:'') –dimension name (for error messages).
Returns:
-
int | ndarray | slice–int, numpy.ndarray or slice: positional indexer.
_sel_label ¶
_sel_label(values: ndarray, label: Any, method: SelMethod | None = None, dim: str = '') -> int
Return the position of one label in the coordinate values.
_selectable_dimensions ¶
_selectable_dimensions(metadata: ArrayMetadata) -> dict[str, Any]
Return the selectable (non-spatial) dimensions and their zarr-coords coordinates.
Describes the values users can pass to sel (e.g to build a visual product).
Dimensions without coordinates get a default (position based) interval.
_to_datetime64 ¶
_to_datetime64(value: Any) -> datetime64
Convert a datetime-like value (ISO 8601 string, date, datetime) to a UTC naive datetime64[ns].
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.
find_convention ¶
find_convention(conventions: list[dict], uuid: str) -> bool
Check if a specific convention is present in the list of conventions.
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.