Skip to content

Validation

Functions for validating convention compliance.

geozarr_toolkit.validate_spatial

validate_spatial(attrs: dict[str, Any]) -> tuple[bool, list[str]]

Validate attributes against the spatial: convention.

Parameters:

  • attrs (dict) –

    Attributes dictionary to validate.

Returns:

Example

is_valid, errors = validate_spatial({
    "spatial:dimensions": ["Y", "X"],
    "spatial:transform": [10.0, 0.0, 500000.0, 0.0, -10.0, 5000000.0],
})
True

geozarr_toolkit.validate_proj

validate_proj(attrs: dict[str, Any]) -> tuple[bool, list[str]]

Validate attributes against the proj: convention.

Parameters:

  • attrs (dict) –

    Attributes dictionary to validate.

Returns:

geozarr_toolkit.validate_multiscales

validate_multiscales(attrs: dict[str, Any]) -> tuple[bool, list[str]]

Validate attributes against the multiscales convention.

Parameters:

  • attrs (dict) –

    Attributes dictionary to validate. Should have 'multiscales' key.

Returns:

geozarr_toolkit.validate_group

validate_group(
    group: Group, conventions: list[str] | None = None
) -> dict[str, list[str]]

Validate a Zarr group against specified conventions.

Parameters:

  • group (Group) –

    Zarr group to validate.

  • conventions (list[str], default: None ) –

    Conventions to validate against. If None, auto-detects. Options: "spatial", "proj", "multiscales"

Returns:

  • dict[str, list[str]]

    Dictionary mapping convention names to lists of errors. Empty error list means validation passed.

Example
import zarr
group = zarr.open_group("path/to/data.zarr")
results = validate_group(group)
for conv, errors in results.items():
    if errors:
        print(f"{conv}: {errors}")

geozarr_toolkit.validate_attrs

validate_attrs(
    attrs: dict[str, Any], conventions: list[str] | None = None
) -> dict[str, list[str]]

Validate attributes dictionary against specified conventions.

Parameters:

  • attrs (dict) –

    Attributes dictionary to validate.

  • conventions (list[str], default: None ) –

    Conventions to validate. If None, auto-detects.

Returns:

  • dict[str, list[str]]

    Dictionary mapping convention names to lists of errors.

geozarr_toolkit.detect_conventions

detect_conventions(attrs: dict[str, Any]) -> list[str]

Detect which GeoZarr conventions are present in attributes.

Parameters:

  • attrs (dict) –

    Attributes dictionary to inspect.

Returns:

  • list[str]

    List of detected convention names.