Open-EO / openeo-gfmap

Generic framework for EO mapping applications building on openEO
Apache License 2.0
4 stars 0 forks source link

Implement virtual band on collection fetchers #98

Open GriffinBabe opened 2 months ago

GriffinBabe commented 2 months ago

At the moment, users can only compute special bands by manually using the openEO client and then merging the compute cubes in the collection fetcher parameters. For example:

bands = ["S2-L2A-B04", "S2-L2A-B03", "S2-L2A-B02"]

# Compute the SCL dilation mask
scl_cube = connection.load_collection(
    collection_id="SENTINEL2_L2A",
    bands=["SCL"],
    temporal_extent=temporal_extent,
    spatial_extent=spatial_extent
)
scl_dilated_mask = scl_cube.process(
    "to_scl_dilation_mask",
    data=scl_cube,
    scl_band_name="SCL",
).rename_labels("bands", ["S2-L2A-SCL_DILATED_MASK"])

extraction_parameters = {
    "pre-merge": scl_dilated_mask,
}

extractor = build_sentinel2_l2a_extractor(
    backend_context,
    bands=bands,
    fetch_type=fetch_type,
    **extraction_parameters,
)

While the pre-merge field remains important for high level, custom pipelines, many common bands such as results to the SCL dilation or the BAP cloud distance could be directly computed by simply adding a new band.

bands = ["S2-L2A-B04", "S2-L2A-B03", "S2-L2A-B02", "S2-SCL_DILATED_MASK"]

A virtual layer logic could be triggered within the extractor to take care of those bands.