Open-EO / openeo-python-client

Python client API for OpenEO
https://open-eo.github.io/openeo-python-client/
Apache License 2.0
156 stars 42 forks source link

Extend applicability of "awesome spectral indices" wrapper beyond pure `load_collection` data #485

Closed mbuchhorn closed 1 year ago

mbuchhorn commented 1 year ago

currently the usage of the spectral_indices functions (compute_and_rescale_indices, append_and_rescale_indices, compute_indices, append_indices, compute_index, append_index) only works when the metadata of the DataCube is valid and includes one of the given collection_id strings expressed in the _get_expression_map check. This is limiting the usage of the functions a lot for DataCubes not directly generated from a collection (imported, merged from different datasets, ....).

Solution: add an optional parameter to the functions to provide a custom dictionary mapping the band names of the input DataCube to the standardized band names used by the awesome package.

jdries commented 1 year ago

load_stac: solution could be to retrieve metadata client side

soxofaan commented 1 year ago

as noted at #501:

I now also added a new argument platform to append_index, compute_index, ... to explicitly specify the satellite platform if the cube metadata has no id (or it's unhandled). e.g.

cube = compute_index(cube, index="NDVI", platform="Sentinel2")

This platform parameter will be used to determine the band name mapping

Does this already address this issue @mbuchhorn or do you also need the following?

... an optional parameter to the functions to provide a custom dictionary mapping the band names of the input DataCube to the standardized band names used by the awesome package.

mbuchhorn commented 1 year ago

@soxofaan yes.. the optional parameter would be helpfull since sometimes we generate "Frankenstein" input datacube which are already S1+S2 data. then to hand over a dictionary to map the band names to standard awesome package band names would be good.

BTW: have to also adapted the current band names for Sentinel-2 (in your CONSTANT dictionary) --> B8A should be N2 and not RE4

Also: please add the CollectionID Sentinel1_GRD to the Sentinel1 handling

soxofaan commented 1 year ago

I now added option to manually specify the band mapping (instead of being guessed from collection id that might be missing). Documented at https://open-eo.github.io/openeo-python-client/cookbook/spectral_indices.html#band-mapping

band names for Sentinel-2 (in your CONSTANT dictionary) --> B8A should be N2 and not RE4

is also fixed now

please add the CollectionID Sentinel1_GRD to the Sentinel1 handling

This should be picked up correctly too