GeoZarr convention models, validation, and creation utilities
Project description
geozarr-toolkit
Python library for creating and validating GeoZarr-compliant metadata. Provides Pydantic models, helper functions, and a CLI for the modular Zarr conventions:
- spatial: -- Coordinate transforms between array indices and spatial coordinates
- proj: -- Coordinate Reference System (CRS) via EPSG codes, WKT2, or PROJJSON
- multiscales -- Pyramid structures and resolution levels
Installation
pip install "geozarr-toolkit @ git+https://github.com/zarr-developers/geozarr-toolkit.git"
Quick start
Create complete GeoZarr-compliant attributes in one call:
from geozarr_toolkit import create_geozarr_attrs
attrs = create_geozarr_attrs(
dimensions=["Y", "X"],
crs="EPSG:32633",
transform=[10.0, 0.0, 500000.0, 0.0, -10.0, 5000000.0],
bbox=[500000.0, 4900000.0, 600000.0, 5000000.0],
shape=[10000, 10000],
)
Or build conventions individually:
from geozarr_toolkit import (
create_spatial_attrs,
create_proj_attrs,
create_zarr_conventions,
SpatialConventionMetadata,
ProjConventionMetadata,
)
# Spatial convention
spatial_attrs = create_spatial_attrs(
dimensions=["Y", "X"],
transform=[10.0, 0.0, 500000.0, 0.0, -10.0, 5000000.0],
)
# Proj convention
proj_attrs = create_proj_attrs(code="EPSG:32633")
# Combine with zarr_conventions array
attrs = {**spatial_attrs, **proj_attrs}
attrs["zarr_conventions"] = create_zarr_conventions(
SpatialConventionMetadata(),
ProjConventionMetadata(),
)
Validation
Validate attributes or Zarr stores against conventions:
from geozarr_toolkit import validate_spatial, validate_proj, detect_conventions
# Validate individual conventions
is_valid, errors = validate_spatial({"spatial:dimensions": ["Y", "X"]})
# Auto-detect and validate all conventions in a dict
from geozarr_toolkit import validate_attrs
results = validate_attrs(attrs)
Working with existing data
Extract convention metadata from rioxarray or GDAL GeoTransforms:
from geozarr_toolkit import from_rioxarray, from_geotransform
# From rioxarray DataArray
attrs = from_rioxarray(da)
# From GDAL GeoTransform
attrs = from_geotransform(
geotransform=(500000.0, 10.0, 0.0, 5000000.0, 0.0, -10.0),
crs_wkt='PROJCS["UTM zone 33N"]',
shape=(10000, 10000),
)
Pydantic models
Use the models directly for type-safe construction and validation:
from geozarr_toolkit import Spatial, Proj
spatial = Spatial(**{"spatial:dimensions": ["Y", "X"]})
proj = Proj(**{"proj:code": "EPSG:4326"})
# Serialize with convention-prefixed keys
attrs = spatial.model_dump(by_alias=True, exclude_none=True)
CLI
# Validate a Zarr store
geozarr validate data.zarr
geozarr validate data.zarr --conventions spatial proj
# Inspect a Zarr store
geozarr info data.zarr
geozarr info data.zarr --json
metazarr
metazarr/ is a client-side JavaScript library and web app for exploring Zarr store hierarchies and validating GeoZarr convention compliance. It runs entirely in the browser with no server required. Deployed at inspect.geozarr.org.
Features:
- Opens remote Zarr v2 and v3 stores (consolidated metadata, directory crawling, or manual path entry)
- Displays full array metadata: shape, dtype, chunks, fill value, codecs/compressor, dimension names, chunk key encoding, memory order, and computed statistics (uncompressed size, chunk count, chunk size)
- Detects sharding (v3
sharding_indexedcodec) - Auto-detects GeoZarr conventions (spatial:, proj:, multiscales, CF) via
zarr_conventionsor attribute prefixes - Validates nodes against convention JSON Schemas (Draft-07 and Draft 2020-12)
cd metazarr
npm install
npm run dev # Start dev server at http://localhost:5173
npm test # Run test suite
Also usable as an ES module:
import { openStore, buildTree, detectConventions, validateNode, buildNodeDocument } from "metazarr";
const result = await openStore("https://example.com/data.zarr");
const tree = buildTreeFromV3(result.v3Entries);
const conventions = detectConventions(tree.attrs);
Development
git clone https://github.com/zarr-developers/geozarr-toolkit.git
cd geozarr-toolkit
uv sync
uv run pytest
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geozarr_toolkit-0.1.0b1.tar.gz.
File metadata
- Download URL: geozarr_toolkit-0.1.0b1.tar.gz
- Upload date:
- Size: 72.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2b8ba0323e7cf544bdaf8567e9814e6e2de36a2364f99cfa28aa98472141bce
|
|
| MD5 |
b0fadb0c5a0c4ac3ffbb145a359ce903
|
|
| BLAKE2b-256 |
fdbfc4a3b7156ab4afbaed427328ef6679e4d5659d8b907080a2068871aed965
|
Provenance
The following attestation bundles were made for geozarr_toolkit-0.1.0b1.tar.gz:
Publisher:
release.yml on zarr-developers/geozarr-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geozarr_toolkit-0.1.0b1.tar.gz -
Subject digest:
d2b8ba0323e7cf544bdaf8567e9814e6e2de36a2364f99cfa28aa98472141bce - Sigstore transparency entry: 977345934
- Sigstore integration time:
-
Permalink:
zarr-developers/geozarr-toolkit@55c16c578413938ec90ff981faa5cac4987e3494 -
Branch / Tag:
refs/tags/v0.1.0b1 - Owner: https://github.com/zarr-developers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55c16c578413938ec90ff981faa5cac4987e3494 -
Trigger Event:
push
-
Statement type:
File details
Details for the file geozarr_toolkit-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: geozarr_toolkit-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1e100c44bebfb36f48cee8839b4072e1a8ceba0d9a61a5c4b37fa86ed4721e4
|
|
| MD5 |
521fb466e72f5546a52aad2d99a62615
|
|
| BLAKE2b-256 |
ce9cb5b5eff948e5f996cca4588a6c3e0b26fd465714ff3c95f8b4d7c48090df
|
Provenance
The following attestation bundles were made for geozarr_toolkit-0.1.0b1-py3-none-any.whl:
Publisher:
release.yml on zarr-developers/geozarr-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
geozarr_toolkit-0.1.0b1-py3-none-any.whl -
Subject digest:
d1e100c44bebfb36f48cee8839b4072e1a8ceba0d9a61a5c4b37fa86ed4721e4 - Sigstore transparency entry: 977346064
- Sigstore integration time:
-
Permalink:
zarr-developers/geozarr-toolkit@55c16c578413938ec90ff981faa5cac4987e3494 -
Branch / Tag:
refs/tags/v0.1.0b1 - Owner: https://github.com/zarr-developers
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55c16c578413938ec90ff981faa5cac4987e3494 -
Trigger Event:
push
-
Statement type: