rasteret.ingest.enrich¶
Shared COG header enrichment logic used by both StacCollectionBuilder
and RecordTableBuilder. See Architecture
for how enrichment fits into the data flow.
enrich
¶
COG header enrichment: shared logic for adding {band}_metadata columns.
Both :class:StacCollectionBuilder and :class:RecordTableBuilder
converge here after extracting per-band URLs from their source-specific
formats. The two entry points are:
- :func:
add_band_metadata_columns: append struct columns from already-parsed results (used when the caller drives parsing itself). - :func:
enrich_table_with_cog_metadata, full async pipeline: extract URLs, parse COG headers, append columns.
Classes¶
Functions¶
slice_tile_tables_for_band
¶
slice_tile_tables_for_band(
*, metadata: Any, band_index: int
) -> tuple[list[int] | None, list[int] | None]
Select per-band tile tables for planar separate multi-sample TIFFs.
For tiled GeoTIFFs with PlanarConfiguration=2, GeoTIFF encodes TileOffsets/TileByteCounts as:
[all tiles for sample 0] + [all tiles for sample 1] + ...
Rasteret's reader expects one tile table per band. During enrichment we
slice the shared table based on band_index so each {band}_metadata
column contains only the offsets for that band.
Source code in src/rasteret/ingest/enrich.py
build_url_index_from_assets
¶
build_url_index_from_assets(
table: Table, band_codes: list[str] | None = None
) -> dict[str, dict[str, dict[str, Any]]]
Build {record_id: {band_code: {url, band_index}}} from assets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
Must contain |
required |
band_codes
|
list of str
|
If given, only include these bands. Otherwise include all. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Nested mapping of record ID -> band code -> asset reference dict. The asset reference dict contains:
|
Source code in src/rasteret/ingest/enrich.py
add_band_metadata_columns
¶
add_band_metadata_columns(
table: Table,
band_codes: list[str],
processed_items: list[dict],
) -> Table
Append {band}_metadata struct columns from parsed COG headers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
Arrow table with an |
required |
band_codes
|
list of str
|
Band codes to create columns for. |
required |
processed_items
|
list of dict
|
Each dict must have |
required |
Returns:
| Type | Description |
|---|---|
Table
|
Input table with |
Source code in src/rasteret/ingest/enrich.py
enrich_table_with_cog_metadata
async
¶
enrich_table_with_cog_metadata(
table: Table,
url_index: dict[str, dict[str, dict[str, Any]]],
band_codes: list[str],
*,
max_concurrent: int = 300,
batch_size: int = 100,
backend: StorageBackend | None = None,
) -> Table
Parse COG headers and add {band}_metadata columns.
This is the high-level entry point for builders that have a
url_index but have not yet parsed COG headers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
Table
|
Arrow table with an |
required |
url_index
|
dict
|
Mapping of |
required |
band_codes
|
list of str
|
Band codes to create metadata columns for. |
required |
max_concurrent
|
int
|
Maximum concurrent HTTP connections. |
300
|
batch_size
|
int
|
Batch size for COG header parsing. |
100
|
backend
|
StorageBackend
|
I/O backend for authenticated range reads during COG header parsing. When omitted, uses the default auto-detecting backend. |
None
|
Returns:
| Type | Description |
|---|---|
Table
|
Table with |
Source code in src/rasteret/ingest/enrich.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | |