Skip to content

feat: add STAC Item/Collection generator for TerraMind embeddings - #330

Merged
romeokienzler merged 4 commits into
mainfrom
feature/stac-embedding-catalog
Nov 20, 2026
Merged

romeokienzler merged 4 commits into
mainfrom
feature/stac-embedding-catalog

Conversation

@romeokienzler

Copy link
Copy Markdown
Member

What

Adds a reusable CLAIMED component at src/claimed/components/geo/stac/create_stac_items.py that catalogs the Embed2Scale TerraMind embedding GeoTIFFs as STAC.

The GeoTIFFs are served from the CloudFerro Swift container at
https://s3.waw4-1.cloudferro.com/swift/v1/embed2scale-terramind/. The component pages
through that listing and writes one STAC Item per GeoTIFF, plus the parent Collection
grouping them.

Item and Collection structure follow the 1st CNG Geo-Embeddings sprint community
recommendation, sections 3.2 and 3.3 of
catalog_guide.ipynb.

How

  • Paging. The Swift listing returns no NextMarker, so the marker for the next
    page is taken from the last entry of the current one. --max-pages bounds the walk.
  • Header-only reads. Each GeoTIFF is opened over GDAL /vsicurl/ and only its TIFF
    header is read — CRS, geotransform, band count, data type. No raster blocks are
    decoded. Measured cost is ~32 KB of range requests (first and last 16 KB) against each
    4.5 MB file, so cataloging thousands of embeddings never downloads the rasters.
  • CLAIMED inputs. output_dir, page_size, max_pages and workers are accepted
    as CLI flags and as environment variables, the convention the other CLAIMED Python
    operators use, so c3_create_operator can surface them as component inputs.

Notes for review

  • The Collection deliberately omits the projection extension. The Items span many UTM
    zones (EPSG:32613, EPSG:32614, …), so there is no single collection-level
    proj:code to state. The notebook's single-tile example can use EPSG:4326; that
    would be misleading across a multi-zone collection. data_type and the emb:*
    properties are promoted to the Collection only when every Item agrees on them.
  • Generated Items are reproducible output of the script and are gitignored rather than
    committed (~13 MB for three pages).
  • The .gitignore hunk also carries entries for macOS archive cruft and the externally
    cloned geo/Demo/ data, which were already present uncommitted in the working tree.

Verification

Ran against the live container for the first 3 listing pages:

Page 1: 1000 objects, 1000 GeoTIFFs, 1000 written, 0 failed
Page 2: 1000 objects, 1000 GeoTIFFs, 1000 written, 0 failed
Page 3: 1000 objects, 1000 GeoTIFFs, 1000 written, 0 failed
Done: 3000 STAC Items written, 0 failed
  • A 30-Item random sample and the Collection all pass pystac.validate() against the
    STAC 1.1.0 schemas plus embeddings/v1.0.0 and projection/v2.1.0.
  • Resulting Collection extent: [-105.0003, 35.1046, -79.6617, 49.6527],
    2017-01-02T17:57:32Z → 2017-03-20T17:40:21Z, with 3000 rel="item" links that resolve.
  • Promoted Collection fields: data_type: float32, emb:type: chip,
    emb:dimensions: [768], emb:chip_size: [256, 256], emb:stride: [256, 256].

🤖 Generated with Claude Code

Catalogs the Embed2Scale TerraMind embedding GeoTIFFs served from the
CloudFerro Swift container as STAC, following the CNG Geo-Embeddings
community recommendation (catalog_guide.ipynb sections 3.2 and 3.3).

The container listing is paged via the Swift marker parameter, and each
GeoTIFF is opened over GDAL /vsicurl/ to read only its TIFF header --
CRS, geotransform, band count and data type -- so cataloging costs about
32 KB of range requests per 4.5 MB file rather than a full download.

Inputs are exposed as both CLI flags and environment variables
(output_dir, page_size, max_pages, workers) so c3_create_operator can
surface them as component inputs.

The Collection omits the projection extension because the Items span
many UTM zones, leaving no single collection-level proj:code.

Generated Items are reproducible output and are gitignored.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Generated components fail before cataloging because the strict parser rejects CLAIMED’s name=value inputs and the default image lacks the required GDAL bindings and native library.

3 open issues
What changed in this PR

Adds a STAC catalog generator for TerraMind embedding GeoTIFFs to CLAIMED’s geospatial components.

Changes:

  • Pages through the CloudFerro Swift listing and reads GeoTIFF headers concurrently without decoding raster pixels.
  • Writes STAC Items and a parent Collection with aggregated extents and shared embedding metadata.
  • Adds CLI and environment-variable controls, and ignores generated catalogs and local artifacts.
File Description
src/​claimed/​components/​geo/​stac/​create_stac_items.py Implements listing pagination, header extraction, and STAC Item/Collection generation.
.gitignore Excludes generated STAC output, external demo data, and macOS archive artifacts.

Review effort: Balanced

@blumenstiel

Copy link
Copy Markdown
Collaborator

@romeokienzler See review from copilot above, not sure if these are actually needed.

branch also out of date, so you need to update it before merging. Let me know once I should review.

- Declare the GDAL wheel via a `pip install` line so c3_create_operator
  puts it in the generated image.
- Accept CLAIMED name=value inputs in the argument parser.
- Only promote an Item property to the Collection if every Item has it.

Signed-off-by: Romeo Kienzler <romeo.kienzler1@ibm.com>
@romeokienzler

Copy link
Copy Markdown
Member Author

@blumenstiel the branch is updated with main, and the Copilot comments were real, so I fixed all three (6635294) and resolved the threads:

  1. GDAL not in the generated image. Added a pip install gdal==3.10.3.post1 --extra-index-url … line that the compiler picks up. Checked that osgeo imports in the default ubi8/python-312 base image.
  2. name=value inputs rejected. The parser now ignores them (the setup code already puts them in the environment) and still rejects other unknown args.
  3. Collection promotion. Now only promotes a property if every Item has it.

Ready for your review.

@blumenstiel blumenstiel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread .gitignore
src/claimed/components/geo/Demo/

# Generated STAC Items and Collection (reproducible via create_stac_items.py)
src/claimed/components/geo/stac/out/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed? Looks more like local files.

I, Romeo Kienzler <romeo.kienzler1@ibm.com>, hereby add my Signed-off-by to this commit: 33b2930

Signed-off-by: Romeo Kienzler <romeo.kienzler1@ibm.com>
@romeokienzler
romeokienzler merged commit 0e23681 into main Nov 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants