Python types and utilities for Zarr Conventions Metadata.
zarr-cm provides typed Python support for the published Zarr conventions:
| Convention | Module | Description |
|---|---|---|
| geo-proj | zarr_cm.geo_proj |
Coordinate reference system information |
| spatial | zarr_cm.spatial |
Spatial coordinate metadata |
| multiscales | zarr_cm.multiscales |
Multiscale pyramid layout |
| license | zarr_cm.license |
License specifiers |
| uom | zarr_cm.uom |
Units of measurement |
Each module provides:
- TypedDict types for convention-specific metadata
create— create convention metadatainsert— add convention metadata to a Zarr attributes dictextract— remove and return convention metadata from an attributes dictvalidate— check runtime invariants the type system cannot express
pip install zarr-cmfrom zarr_cm import geo_proj
# Create convention metadata
data = geo_proj.create(code="EPSG:4326")
print(data)
#> {'proj:code': 'EPSG:4326'}
# Validate
print(geo_proj.validate({"proj:code": "EPSG:4326"}))
#> {'proj:code': 'EPSG:4326'}
# Insert into an attributes dict
attrs = {"foo": "bar"}
result = geo_proj.insert(attrs, data)
print(result)
"""
{
'foo': 'bar',
'proj:code': 'EPSG:4326',
'zarr_conventions': [
{
'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f',
'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json',
'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md',
'name': 'proj:',
'description': 'Coordinate reference system information for geospatial data',
}
],
}
"""
# Extract it back out
remaining, extracted = geo_proj.extract(result)
print(remaining)
#> {'foo': 'bar'}
print(extracted)
#> {'proj:code': 'EPSG:4326'}