Spark Metadata Extraction¶
geoembed.metadata.spark
¶
Spark-based distributed metadata extraction for GeoTIFF imagery.
Scans a Unity Catalog Volume (or any path) for GeoTIFF files, extracts spatial and temporal metadata from headers + XML sidecars in parallel across Spark workers, and writes results to a Delta table.
This is typically the FIRST stage of the pipeline — it creates the metadata table that subsequent stages (COG conversion, chipping) read from.
MetadataExtractionConfig(volume_path, output_table, glob_pattern='*.tif', recursive=True)
dataclass
¶
Configuration for Spark-based metadata extraction.
Attributes:
| Name | Type | Description |
|---|---|---|
volume_path |
str
|
Path to scan for GeoTIFFs (Unity Catalog Volume or local). |
output_table |
str
|
Delta table to write metadata to. |
glob_pattern |
str
|
File pattern to match (default: "*.tif"). |
recursive |
bool
|
Scan subdirectories recursively. |
MetadataExtractionWorker
¶
Spark mapInPandas worker for distributed metadata extraction.
Initialises GDAL optimisations and metadata readers once per partition, then processes batches of file paths. Extracts: - Spatial bounds and geometry (from GeoTIFF header via rasterio) - Temporal extent, EPSG, and provider (from XML sidecar if present)
The worker is serialised to executors — keep it lightweight at init time.
SparkMetadataExtractor(spark, config)
¶
Distributed metadata extraction pipeline for Databricks.
Scans a Unity Catalog Volume for GeoTIFFs, distributes header reading across Spark workers, and writes a Delta metadata table.
Usage
from geoembed.metadata.spark import SparkMetadataExtractor, MetadataExtractionConfig
config = MetadataExtractionConfig( volume_path="/Volumes/catalog/schema/raw_imagery", output_table="catalog.schema.imagery_metadata", ) extractor = SparkMetadataExtractor(spark, config) extractor.run()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spark
|
Any
|
Active SparkSession. |
required |
config
|
MetadataExtractionConfig
|
Extraction configuration. |
required |
Source code in src/geoembed/metadata/spark.py
run()
¶
Execute the metadata extraction pipeline.
Scans the volume, distributes extraction, writes to Delta with native geometry.