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:
-
landcover_classes(List[int]) -
material_library(PathRef) -
clusters_per_class(int) -
acquisition_date(str) -
search_window_days(int) -
max_cloud_cover(float) -
bands(List[str]) -
stac_url(str) -
credential_id(Optional[str]) -
random_seed(Optional[int]) -
max_sam_angle_deg(Optional[float])
Validators:
-
_validate_library_exists→material_library -
_validate_date→acquisition_date -
_validate_bands→bands
Attributes
acquisition_date
pydantic-field
Anchor acquisition date 'YYYY-MM-DD' for the Sentinel-2 composite.
clusters_per_class
pydantic-field
Number of k-means clusters per diversified landcover class.
credential_id
pydantic-field
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
ESA WorldCover class codes to diversify (e.g. [30, 60]).
material_library
pydantic-field
Path to a materials.json-style file. Only its 'diffuse' entries are used as candidate materials for spectral matching.
max_cloud_cover
pydantic-field
Maximum eo:cloud_cover (percent) for candidate scenes.
max_sam_angle_deg
pydantic-field
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
Seed for reproducible k-means clustering.
search_window_days
pydantic-field
± days around acquisition_date to search for usable scenes.