Skip to content

Spectral Matching

Configuration for diversifying landcover classes into real materials matched from satellite imagery. See Spectral material matching for the concept, Spectral material matching configuration for usage, and the Spectral Matching processors for the underlying functions.

s2gos_generator.core.config.material_match.SpectralMatchingConfig pydantic-model

Bases: BaseModel

Spectral matching of selected landcover classes.

Presence (non-None) on SceneGenConfig enables the feature. For each listed landcover class the generator fetches Sentinel-2 reflectance, k-means clusters the pixels of that class, and matches each cluster to the best-fitting diffuse material from material_library via Spectral Angle Mapper — painting those richer materials into the selection texture instead of a single flat index.

Copernicus credentials are resolved by credential_id through the settings/secrets credential provider (.secrets.yaml), never embedded here.

Fields:

Validators:

Attributes

acquisition_date pydantic-field

acquisition_date: str

Anchor acquisition date 'YYYY-MM-DD' for the Sentinel-2 composite.

bands pydantic-field

bands: List[str]

Sentinel-2 10 m bands used for matching.

clusters_per_class pydantic-field

clusters_per_class: int = 4

Number of k-means clusters per diversified landcover class.

credential_id pydantic-field

credential_id: Optional[str] = None

Id of an s3 credential (in .secrets.yaml / settings) used to read the Copernicus 'eodata' bucket. None falls back to ambient AWS_* env vars.

landcover_classes pydantic-field

landcover_classes: List[int]

ESA WorldCover class codes to diversify (e.g. [30, 60]).

material_library pydantic-field

material_library: PathRef

Path to a materials.json-style file. Only its 'diffuse' entries are used as candidate materials for spectral matching.

max_cloud_cover pydantic-field

max_cloud_cover: float = 5.0

Maximum eo:cloud_cover (percent) for candidate scenes.

max_sam_angle_deg pydantic-field

max_sam_angle_deg: Optional[float] = None

If set, clusters whose best SAM angle exceeds this threshold keep their base landcover material instead of a spectral match (quality gate).

random_seed pydantic-field

random_seed: Optional[int] = None

Seed for reproducible k-means clustering.

search_window_days pydantic-field

search_window_days: int = 310

± days around acquisition_date to search for usable scenes.

stac_url pydantic-field

stac_url: str = 'https://stac.dataspace.copernicus.eu/v1'

STAC catalog endpoint.