Skip to content

Creation

Functions for creating convention-compliant metadata.

geozarr_toolkit.create_zarr_conventions

create_zarr_conventions(
    *conventions: ZarrConventionMetadata,
) -> list[dict[str, Any]]

Create a zarr_conventions array from convention metadata objects.

Parameters:

Returns:

  • list[dict[str, Any]]

    List of convention metadata dictionaries suitable for zarr_conventions.

Example
from geozarr_toolkit.conventions import (
    SpatialConventionMetadata,
    ProjConventionMetadata,
)
conventions = create_zarr_conventions(
    SpatialConventionMetadata(),
    ProjConventionMetadata(),
)

geozarr_toolkit.create_spatial_attrs

create_spatial_attrs(
    dimensions: list[str],
    *,
    transform: tuple[float, ...] | list[float] | None = None,
    bbox: tuple[float, ...] | list[float] | None = None,
    shape: tuple[int, ...] | list[int] | None = None,
    registration: str = "pixel",
) -> dict[str, Any]

Create spatial: convention attributes.

Parameters:

  • dimensions (list[str]) –

    Names of spatial dimensions, e.g., ["Y", "X"].

  • transform (tuple or list of float, default: None ) –

    Affine transformation coefficients [a, b, c, d, e, f].

  • bbox (tuple or list of float, default: None ) –

    Bounding box [xmin, ymin, xmax, ymax].

  • shape (tuple or list of int, default: None ) –

    Spatial shape [height, width].

  • registration (str, default: "pixel" ) –

    Grid registration type: "pixel" or "node".

Returns:

  • dict[str, Any]

    Dictionary of spatial: convention attributes.

geozarr_toolkit.create_proj_attrs

create_proj_attrs(
    *,
    code: str | None = None,
    wkt2: str | None = None,
    projjson: dict[str, Any] | None = None,
) -> dict[str, Any]

Create proj: convention attributes.

At least one of code, wkt2, or projjson must be provided.

Parameters:

  • code (str, default: None ) –

    EPSG code, e.g., "EPSG:4326".

  • wkt2 (str, default: None ) –

    WKT2 CRS string.

  • projjson (dict, default: None ) –

    PROJJSON CRS dictionary.

Returns:

  • dict[str, Any]

    Dictionary of proj: convention attributes.

geozarr_toolkit.create_multiscales_layout

create_multiscales_layout(
    levels: list[dict[str, Any]], *, resampling_method: str | None = None
) -> dict[str, Any]

Create multiscales convention layout.

Parameters:

  • levels (list[dict]) –

    List of level dictionaries. Each must have 'asset' key. Optional keys: 'derived_from', 'transform', 'resampling_method'.

  • resampling_method (str, default: None ) –

    Default resampling method for all levels.

Returns:

  • dict[str, Any]

    Dictionary with 'multiscales' key containing the layout.

Example
layout = create_multiscales_layout([
    {"asset": "0"},
    {"asset": "1", "derived_from": "0", "transform": {"scale": [2.0, 2.0]}},
])

geozarr_toolkit.create_geozarr_attrs

create_geozarr_attrs(
    dimensions: list[str],
    *,
    crs: str | None = None,
    transform: tuple[float, ...] | list[float] | None = None,
    bbox: tuple[float, ...] | list[float] | None = None,
    shape: tuple[int, ...] | list[int] | None = None,
    registration: str = "pixel",
    include_conventions: bool = True,
) -> dict[str, Any]

Create complete GeoZarr-compliant attributes with zarr_conventions.

Parameters:

  • dimensions (list[str]) –

    Names of spatial dimensions.

  • crs (str, default: None ) –

    EPSG code (e.g., "EPSG:4326") or WKT2 string.

  • transform (tuple or list of float, default: None ) –

    Affine transformation coefficients.

  • bbox (tuple or list of float, default: None ) –

    Bounding box.

  • shape (tuple or list of int, default: None ) –

    Spatial shape.

  • registration (str, default: "pixel" ) –

    Grid registration type.

  • include_conventions (bool, default: True ) –

    Whether to include zarr_conventions array.

Returns:

  • dict[str, Any]

    Complete GeoZarr-compliant attributes.