STAC Catalog Generation¶
geoembed.metadata.stac_catalog
¶
STAC catalog generation with Z-order sorted GeoParquet output.
Builds a STAC Catalog → Collection → Items hierarchy and exports items as a GeoParquet 1.1 file with bbox.covering metadata for efficient spatial queries (DuckDB row group predicate pushdown).
StacCatalogConfig(catalog_id, catalog_title, catalog_description, collection_id, collection_title, collection_description, output_path, parquet_compression='zstd', row_group_size=1000)
dataclass
¶
Configuration for STAC catalog generation.
Attributes:
| Name | Type | Description |
|---|---|---|
catalog_id |
str
|
Unique identifier for the catalog. |
catalog_title |
str
|
Human-readable catalog title. |
catalog_description |
str
|
Catalog description. |
collection_id |
str
|
Unique identifier for the collection. |
collection_title |
str
|
Human-readable collection title. |
collection_description |
str
|
Collection description. |
output_path |
str
|
Root directory for the STAC catalog output. |
parquet_compression |
str
|
Compression codec for GeoParquet (zstd, snappy, etc.). |
row_group_size |
int
|
Number of items per Parquet row group. |
compute_collection_extent(item_dicts)
¶
Derive spatial and temporal extents from a list of STAC item dicts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_dicts
|
list[dict]
|
List of STAC item dictionaries. |
required |
Returns:
| Type | Description |
|---|---|
Extent
|
pystac.Extent covering all items. |
Source code in src/geoembed/metadata/stac_catalog.py
sort_by_morton(table, lon_range=(-180.0, 180.0), lat_range=(-90.0, 90.0))
¶
Sort an Arrow table by Z-order (Morton code) on bbox centroids.
Clusters spatially nearby items into the same Parquet row groups so that DuckDB can skip entire row groups when the query bbox doesn't overlap their extent (predicate pushdown via the GeoParquet 1.1 bbox.covering statistics).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
Arrow table with a 'bbox' struct column. |
required |
lon_range
|
tuple[float, float]
|
Longitude normalisation range (min, max). |
(-180.0, 180.0)
|
lat_range
|
tuple[float, float]
|
Latitude normalisation range (min, max). |
(-90.0, 90.0)
|
Returns:
| Type | Description |
|---|---|
Table
|
Spatially sorted Arrow table. |
Source code in src/geoembed/metadata/stac_catalog.py
build_stac_items_from_metadata(metadata_rows, cog_base_path=None)
¶
Convert metadata rows into STAC item dictionaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata_rows
|
list[dict[str, Any]]
|
List of dicts with keys: id, image_path, geometry_wkb, epsg, datetime, provider. |
required |
cog_base_path
|
str | None
|
Optional base path to prepend to image_path for COG assets. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict]
|
List of STAC item dicts (JSON-serialisable). |
Source code in src/geoembed/metadata/stac_catalog.py
generate_stac_catalog(item_dicts, config, lon_range=(-180.0, 180.0), lat_range=(-90.0, 90.0))
¶
Generate a full STAC catalog with Z-order sorted GeoParquet.
Creates: - STAC JSON catalog hierarchy (catalog.json, collection.json) - GeoParquet 1.1 file with bbox.covering metadata
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item_dicts
|
list[dict]
|
List of STAC item dictionaries. |
required |
config
|
StacCatalogConfig
|
Catalog configuration. |
required |
lon_range
|
tuple[float, float]
|
Longitude range for Morton code normalisation. |
(-180.0, 180.0)
|
lat_range
|
tuple[float, float]
|
Latitude range for Morton code normalisation. |
(-90.0, 90.0)
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the generated GeoParquet file. |
Source code in src/geoembed/metadata/stac_catalog.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |