Design note · catalog storage

Level 2 collections in GeoStack

The CNG Forum 2026 talk by Tom Nicholas (Earthmover) and Sean Harkins (Development Seed) keeps a STAC-like catalog inside the same Zarr store as the scenes it indexes, so Icechunk can commit data and metadata together. This page checks what GeoStack already does against the code, then shows the smallest change that brings that idea in.

geostack 343d60e geotoolz 640670c xrtoolz 995a151 pipekit 9e86a56

Summary

The carriers and lanes stay as they are. geocatalog already holds a table catalog, and geoarray and xrops already speak DataTree. The change is in where the catalog table lives and how products get written into it.

End state. geocatalog owns the catalog on any of three backends and the write path; geoarray keeps its carriers and converters; geoops, xrops and pipekit do not change; the repo holds scenes, products and their index, versioned together, and is the truth that the product catalog is built from.

Current state · verified in code

How a scene moves through the stack today

Two layers. The top one is the work you do: find, load, compute, write. The bottom one is what persists between tasks: the catalogs you search and the storage you read and write. Every arrow between the layers is a separate I/O call, and nothing ties one call to another.

WORK PERSIST Working catalog InMemory · DuckDB query · matchup 5 2 Load load_raster load_xarray 3 Compute geoarray ⇄ xarray geoops · xrops Write write_cog WriteZarr · to_zarr 4 STACSource reads files writes files Source catalogs Earth Search · PC CMR public, read only Object storage scene files · cubes · outputs COG · JP2 · NetCDF · Zarr geocloud.store (obstore) catalog.parquet the catalog table, written apart from the files it lists 1
The catalog table and the files it lists are separate objects in the same bucket, written by separate calls. Amber numbers mark the five gaps below; the stripe on each box names its repo. Where products are recorded for others is the product catalog doc.
geotoolz xrtoolz pipekit third party 1verified gap

The components, and where each one lives

ComponentRepoWhat it doesRead in
geocatalog.sourcesgeotoolz-catalogDiscovers items from STAC, CMR, earthaccess and GEE. These feed a catalog; they are not the catalog.geocatalog/__init__.py
geocatalog.buildgeotoolz-catalogbuild_raster_catalog and its xarray, vector and state siblings index files into rows; append_files adds files to an existing GeoParquet catalog.geocatalog/build/__init__.py
GeoCataloggeotoolz-catalogThe protocol: query, intersect, union, iter_rows, iter_slices, extents. A query returns a new catalog; there is no append or commit._src/base.py:204
CatalogRowgeotoolz-catalogOne row: filepath, footprint, time interval, CRS and extras (state rows add run, member and producer)._src/base.py:88
InMemoryGeoCatalog, DuckDBGeoCataloggeotoolz-catalogThe two backends. open_catalog picks DuckDB when the extra is installed, else memory._src/factory.py
geocatalog.storagegeotoolz-catalogGeoParquet in and out, STAC export, CatalogBundle, StreamingParquetWriter.geocatalog/storage/__init__.py
load_rastergeotoolz-catalogReads every overlapping row and mosaics it onto the slice grid: the result's grid equals slice_.grid._src/formats/raster.py:494
load_xarray, load_statesgeotoolz-catalogCubes from many files. load_states(group_by=…) already returns a DataTree, one leaf per grid._src/formats/states.py:424
geoarraygeotoolz-arrayGeoArray, GeoSwath, GeoPoints, RasterSource, and the converters to_xarray, to_dataset and to_datatree with their inverses (LL-F3: one node per grid).geoarray/_src/xarray.py:695
geocloudgeotoolz-cloudThe obstore client pool, sync and async COG reads (CogSource, AsyncCogReader), write_cog, a local cache.geocloud/cog.py
geoopsgeotoolz-opsPer-item operators on carriers, including matched_filter and the io sinks such as WriteZarr.geoops/io/_src/operators.py:1181
xrops.Operatorxrtoolz-opsMaps any operator over every DataTree node with xr.map_over_datasets; lift(op, dim) runs a geoops operator per item of a cube.xrops/_src/operator.py:1
pipekit-ops, pipekit-arraypipekitThe Operator base every geoops and xrops operator subclasses; DimArray, KernelOp and the dim-level functions.packages/pipekit-array

Five verified gaps

One doc lag found on the way: labeled_lane.md still lists LL-F3 as open, while to_datatree ships in geoarray 0.4.1.

Revised target

The same flow with the catalog inside the repo

Every box and every line of text from the current diagram is still here, in the same place. Blue text marks what each box gains, with the letter of the workstream that adds it. Compute is faded because it does not change. One box in the persist layer is new: Icechunk repos, beside object storage, which stays.

WORK PERSIST Working catalog InMemory · DuckDB query · matchup + Icechunk A Load load_raster load_xarray + load_scenes C Compute geoarray ⇄ xarray geoops · xrops unchanged Write write_cog WriteZarr · to_zarr + transaction D B STACSource reads files writes files chunks 1 commit Source catalogs Earth Search · PC CMR public, read only + your mirror, optional Object storage scene files · cubes COG · NetCDF · Zarr obstore pool unchanged virtual E Icechunk repos meta/ · scenes/ products/ index and data in one commit products/<algo>/<id>/ with a meta/ row each → product catalog doc A
One repository holds the index, the scenes and your products, and a query, a read and a write all name the same snapshot. Publishing a tagged commit to a product catalog is the product catalog doc.
new surface Aworkstream unchanged

What each workstream adds

SymbolDestinationReasonCloses
IcechunkGeoCataloggeocatalog.backends, extra [icechunk]A third backend with the same protocol; its table lives in meta/ at one snapshot.A · gaps 1, 2
GeoCatalogWriter, CatalogTransactiongeocatalog rootThe write half of the protocol. DuckDB implements append by wrapping append_files; Icechunk implements both.B · gaps 1, 5
load_scenesgeocatalog.loadOne node per row on its own grid, built with geoarray.to_datatree. Works on all three backends.C · gap 3
WriteZarr attributesgeoops.ioWrite the CF spatial_ref that geoarray.to_xarray writes, so one reader opens every product.D · gap 4
ingest_virtualgeocatalog.build, extra [virtual]VirtualiZarr references for COG and NetCDF/HDF5 scenes, written as scenes/<id>/ plus a meta/ row.E · gap 2
The product catalog: ProductCatalog, publish, the record and pgstac sync, in GeoStack product catalog.F, K, L
API sketch

Under the hood

The sketches follow the code-sketch standard. Each opens with a shapes header; a status marker sits on its own line above every call into the stack; a unicode equation sits above every mathematical line; bare assignments end with their shape in one column.

today (pkg)ships at the pinned commit, name and arguments checked in the repo today* (pkg)ships, but some arguments are sketched proposed (X)not shipped; X is the workstream that adds it usera function the reader writes, not a stack name

The today names were checked against the pinned commits. The blocks were not run: they need a catalog of real scenes, which this session does not have.

Repository layout

One repository per collection. Every array in meta/ has shape (R,) for R rows and shares one chunking, so a chunk index acts like a Parquet row group.

s2-l2a-site.icechunk/
├── meta/                    # the catalog table, R rows
│   ├── id                   # str
│   ├── start_time           # datetime64[ms]
│   ├── end_time             # datetime64[ms]
│   ├── geometry             # bytes, WKB in EPSG:4326
│   ├── crs                  # str, the scene's native CRS
│   ├── key                  # str, the group path, e.g. scenes/S2A_20260601_T30SYJ
│   └── cloud_cover          # float32, any extra column
├── indexes/geometry         # optional R-tree over meta/geometry
├── scenes/<id>/              # bands (C, H, W) + CF spatial_ref; virtual or real chunks
├── products/<algo>/<id>/      # outputs, same convention, each with a meta/ row
└── cubes/<name>/             # aligned L3/L4 Datasets

How meta/ maps onto CatalogRow

meta/ columnZarr dtypeCatalogRow field
keyvariable-length strfilepath = "icechunk://<repo>@<snapshot>/<key>"
geometryvariable-length bytes (WKB)geometry, decoded with shapely
start_time, end_timedatetime64[ms]interval, closed on both ends
crsvariable-length strcrs
everything elseany fixed or string dtypeextras

The backend

The catalog is host-side and never traced, so it is a frozen dataclass rather than an Equinox module. A query keeps a row when its footprint meets the slice bounds B and its interval [t₀, t₁] meets the slice interval T.

# geocatalog/_src/backends/icechunk.py
"""A GeoCatalog whose table is the meta/ group of an Icechunk repository."""

import dataclasses
from collections.abc import Iterator
from typing import Any

import icechunk
import numpy as np
import pandas as pd
from jaxtyping import Bool

from geocatalog._src.base import CatalogRow
from geocatalog._src.geoslice import GeoSlice

# Shapes: R rows in meta/; K ≤ R rows kept by queries


@dataclasses.dataclass(frozen=True)
class IcechunkGeoCatalog:
    """Catalog rows read from meta/ at one snapshot.

    Args:
        repo: The repository holding meta/, the scenes and the products.
        uri: Where the repository lives, used to build each row's filepath.
        snapshot: The snapshot every read of this catalog names.
        keep: Rows kept by earlier queries; None keeps all R rows.
    """

    repo: icechunk.Repository
    uri: str
    snapshot: str
    keep: Bool[np.ndarray, "row"] | None = None

    def query(
        self,
        slice_: GeoSlice | None = None,
        *,
        bounds: tuple[float, float, float, float] | None = None,
        crs: Any | None = None,
        time: tuple[Any, Any] | pd.Interval | None = None,
    ) -> "IcechunkGeoCatalog":
        # proposed (A)
        meta_table = read_meta(self.repo, self.snapshot)            # → (R,) table
        # keep ⇔ footprint ∩ B ≠ ∅ ∧ [t₀, t₁] ∩ T ≠ ∅
        # proposed (A)
        overlaps = filter_rows(meta_table, slice_, bounds, crs, time)  # (R,) → (R,)
        # keep ← keep ∧ overlaps
        kept = overlaps if self.keep is None else self.keep & overlaps  # (R,) → (R,)
        return dataclasses.replace(self, keep=kept)

    def iter_rows(self, *, batch_size: int = 1024) -> Iterator[CatalogRow]:
        # proposed (A)
        records = kept_records(self, batch_size=batch_size)          # → (K,)
        for record in records:
            filepath = f"icechunk://{self.uri}@{self.snapshot}/{record.key}"
            # today (geocatalog)
            yield CatalogRow(
                filepath=filepath,
                geometry=record.geometry,
                interval=record.interval,
                crs=record.crs,
                extras=record.extras,
            )

The write half

Two protocols, kept small. DuckDB satisfies the first by wrapping append_files; only Icechunk satisfies the second.

# geocatalog/_src/base.py
"""The write half of the catalog protocol."""

from collections.abc import Mapping, Sequence
from typing import Any, Protocol

from geoarray import GeoArray


class GeoCatalogWriter(Protocol):
    """A catalog that can take new rows."""

    def append(self, rows: Sequence[CatalogRow]) -> None: ...


class CatalogTransaction(Protocol):
    """Writes carriers and their rows, visible only after commit.

    Raises:
        CatalogTransactionError: If the commit conflicts with another writer.
    """

    def put(
        self,
        key: str,
        carrier: GeoArray["band y x"],
        row: Mapping[str, Any],
    ) -> CatalogRow: ...

    def commit(self, message: str) -> str: ...


# proposed (B)
class CatalogTransactionError(GeoCatalogError, RuntimeError):
    """A commit lost a race with another writer on the same branch."""

The scene loader

# geocatalog/_src/formats/raster.py
import geoarray
import xarray as xr
from geoarray import GeoArray

from geocatalog._src.base import GeoCatalog
from geocatalog._src.geoslice import GeoSlice

# Shapes: K rows kept; per scene C bands on its own H × W grid


def load_scenes(
    catalog: GeoCatalog,
    slice_: GeoSlice,
    *,
    group_by: str = "id",
) -> xr.DataTree:
    """One DataTree node per row, each on the row's own grid.

    Algorithm:
        1. Open each kept row as a RasterSource: a file or an icechunk:// group.
        2. Read the slice's bounds on the row's native grid, with no reprojection.
        3. Put each carrier on its own node with geoarray.to_datatree.

    Args:
        catalog: The rows to load, usually the result of a query.
        slice_: The bounds to read from each scene.
        group_by: The row column whose value names each node.
    """
    scenes: dict[str, GeoArray] = {}
    # today (geocatalog)
    for row in catalog.iter_rows():                                 # (K,)
        # proposed (C)
        source = open_source(row.filepath)                          # → RasterSource
        # proposed (C)
        scene = read_bounds(source, slice_)                         # → (C, H, W)
        scenes[row.extras[group_by]] = scene
    # today (geoarray)
    tree = geoarray.to_datatree(scenes)                             # K → K nodes
    return tree
API sketch

In action: matched filter over a month of scenes

The task: run the matched filter on every Sentinel-2 scene over a site in June 2026, keep the outputs, and make them findable. For each pixel, y ∈ ℝᶜ is its spectrum over C bands, μ ∈ ℝᶜ the background mean, Σ ∈ ℝᶜˣᶜ the background covariance, t ∈ ℝᶜ the methane target signature, and α̂ the enhancement. With fit_on_call=True, geoops fits μ and Σ on each scene. site_june is a GeoSlice over the site for June, and extract_row is the reader's own function that turns a file into a row.

from pathlib import Path

import geocatalog
import geocloud.cog
import geoops.matched_filter

# Shapes: R rows in the catalog; S scenes kept; C bands; H × W pixels per scene

# today (geocatalog)
catalog = geocatalog.open_catalog("s3://bkt/s2_site.parquet")   # → R rows
# today (geocatalog)
june = catalog.query(site_june)                                 # R → S rows
# today (geoops)
matched_filter = geoops.matched_filter.MatchedFilter(
    target=methane_target,
    fit_on_call=True,
)

product_paths: list[str] = []
# today (geocatalog)
for row in june.iter_rows():                                    # (S,)
    # today (geocloud)
    source = geocloud.cog.CogSource.open(row.filepath)
    # today (geocloud)
    scene = source.load()                                       # → (C, H, W)
    # α̂ = tᵀ Σ⁻¹ (y − μ) / (tᵀ Σ⁻¹ t)
    # today (geoops)
    enhancement = matched_filter(scene)                         # → (1, H, W)
    scene_id = Path(row.filepath).stem
    product_path = f"s3://bkt/products/mf/{scene_id}.tif"
    # today (geocloud)
    geocloud.cog.write_cog(enhancement, product_path)
    product_paths.append(product_path)

# second write: a crash before this line leaves COGs that no row points at
# today* (geocatalog)
geocatalog.build.append_files(
    "s3://bkt/mf_catalog/",
    product_paths,
    extract_row,
    crs="EPSG:4326",
    kind="raster",
    partition_by=[],
)

The diff

Only the lines that change, current code first. The matched filter call does not change.

# Today:
# today (geocatalog)
catalog = geocatalog.open_catalog("s3://bkt/s2_site.parquet")   # → R rows
# today (geocloud)
geocloud.cog.write_cog(enhancement, product_path)
# today* (geocatalog)
geocatalog.build.append_files(archive, product_paths, extract_row, ...)

# After:
# proposed (A)
catalog = geocatalog.open_catalog("icechunk://s3://bkt/s2_site")  # → R rows
# proposed (B)
transaction.put(f"products/mf/{scene_id}", enhancement, row=row)  # → 1 row
# proposed (B)
snapshot_id = transaction.commit(message)

What the difference is

ConcernTodayTarget
Where the index livesA GeoParquet file beside the datameta/ inside the repo
Registering a productwrite_cog, then append_files: two stepsput, then one commit
A crash halfwayFiles with no rows, or rows with no filesNothing visible; the branch is unchanged
Pinning a training setCopy the Parquet file and hope the files stayKeep the snapshot id
Reading a sceneOpen a file per row (rasterio, obstore)Read Zarr chunks, real or virtual
Many scenes in xarrayMosaic onto one grid, or load_states for states onlyload_scenes → DataTree for any raster rows
A new algorithm versionA new folder by conventionA branch; merge it or drop it
Carriers, geoops, xrops, pipekitUnchanged.

Testing gates

Each workstream merges only when its gate passes.

GateWorkstreamPasses when
A1 Query parityAOn the same rows, IcechunkGeoCatalog.query and DuckDBGeoCatalog.query return identical ids for 100 random GeoSlices, including slices in another CRS.
B1 AtomicityBA transaction that raises before commit leaves main at the same snapshot id, with no new group and no new row.
B2 ReproducibilityBAfter 10 later commits, opening the first snapshot returns the same rows and bit-identical arrays.
C1 Scene parityCEach load_scenes node equals the direct CogSource read of its file bit for bit, and from_datatree returns a Grid equal to the source's.
D1 One conventionDWriteZarr output opens through geoarray.from_xarray with the transform equal to 1e-9 and an equal CRS.
E1 Virtual parityEA virtual scene group reads bit-identical to its source COG or NetCDF on every band.

Sequencing and risks

Products first, because that is where the two-step write hurts today and where the scale is small. Source collections and virtual ingest follow once the backend has proven itself.

  D  one Zarr convention         B  write half (DuckDB append)
      │                              │
      ◆ D1                           ◆ B1
      └──────────────┬───────────────┘
                     │
  A  IcechunkGeoCatalog  ┃  C  load_scenes        (parallel)
                     │
                     ◆ A1 · B2 · C1
                     │
  E  virtual ingest of source scenes
                     │
                     ◆ E1
RecommendedDo D and B first, then A and C for products and derived collections. Keep source-scene catalogs on GeoParquet and DuckDB for now.
AlternativeMove source catalogs too, through E. It gives one index for everything but takes on the node-count risk on day one.

Sources