$ show opendatacube/odc-stac
odc-stac is a Python library that converts STAC (SpatioTemporal Asset Catalog) metadata into the Open Data Cube (ODC) data model, enabling efficient loading of satellite imagery (Sentinel-2, Landsat) into xarray Datasets with Dask support. It defines a pluggable metadata parser (`StacMDParser`) and auxiliary reader (`StacAuxReader`) that integrate with the odc-loader framework, handles STAC extensions for projection, raster, and EO, and provides flexible spatial-temporal binning and grouping. The library also includes a CLI benchmark tool, test utilities for generating synthetic STAC items, and a comprehensive test suite with realistic STAC item fixtures from multiple providers (Planetary Computer, USGS, Geoscience Australia). While primarily an application library, it is used extensively in geospatial data research pipelines. The codebase is well-structured and modular, though it depends on evolving STAC specifications and extensions, introducing moderate technical drift risk.
The LLM identified 4 files worth highlighting for reuse:
Contains `StacMDParser` (implements `MDParser` protocol) and `StacAuxReader` (implements `AuxReader` protocol) for converting STAC item properties and asset metadata into ODC's internal data model. These are isolated, reusable components that can be extracted to bridge any STAC-based data source with ODC loading pipelines. Demonstrates clean separation of concerns and protocol-based design.
Defines frozen dataclasses (`RasterCollectionMetadata`, `ParsedItem`, `PropertyLoadRequest`) that represent parsed STAC metadata in a tokenizable format suitable for Dask lazy evaluation. These models are self-contained and can be reused in other STAC-processing projects that require immutability and hashing for distributed computing.
Provides `make_stac_item` and related functions to construct synthetic STAC items programmatically for testing. This utility is reusable across any project that needs to test STAC ingestion or loading without depending on external APIs or large data files. Demonstrates non-obvious skill in test data generation.
Implements the core `load()` function that orchestrates STAC item parsing, spatial-temporal binning, grouping, and deferred loading into xarray Datasets. While tightly coupled to the rest of the library, its pattern of using a `load()` function with extensive configuration via dataclasses and protocols is a reusable architectural pattern for similar data loading tasks.