-
Notifications
You must be signed in to change notification settings - Fork 41
load_stac - prevent setting metadata to None due to missing band labels #752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Wouldn't this also be fixed by improving the band detection of that stac collection? e.g. #586 |
I also noticed that you are using different band names than the ones listed under "bands" in https://stac.dataspace.copernicus.eu/v1/collections/sentinel-2-l2a: B01, B02, B03, ... so there also some inconsistency here |
Yes the collection contains those bands but the items list the assets at different resolutions as well. In the use-case where I encountered this bug we specifically want to directly load the 60m assets. That is why #586 would not solve this use case. In an ideal world the stac collection would list all the bands with their different resolution, however even with #586 solved we would block the creation of a job due to metadata issues that do not occur on the backend. |
That's the key question I guess: what are the right band names for that collection? For example, if I load that STAC url in this STAC browser https://radiantearth.github.io/stac-browser/#/external/stac.dataspace.copernicus.eu/v1/collections/sentinel-2-l2a , it also detects these bands B01, B02, B03, ... which I'd like the Python client to do too. I think the python client should be as compliant as possible to the official/other STAC tooling, and avoid baking in a conflicting approach that is currently used in a particular backend (ours). I however agree that we should alleviate the impedance mismatch with warnings instead of hard failures |
FYI something that came up in a meeting today (with @m-mohr ): which confirms that the following snippet builds on an invalid assumption that the assets keys imply band names
|
The STAC browser has it easy: it merely has to list bands, not load assets. If assets with different resolutions have the same band name, there's no way to specify exactly which assets to load. Maybe the issue lies with the STAC collection itself? |
@bossie Your statement is not really true, STAC Browser also tries to visualize assets. For this it also needs knowledge of the bands (and it always lists bands as you can see above?!). It tries to detect the best suitable assets and bands based on names or common names first, but let's users pick individual assets. It's fine if you let choose users specific asset keys, but that should likely not be the default. Having that said, the S2 L2A collection from CDSE is indeed a bit weird in that it offers multiple resolutions. I recommended against it, but was overrruled in the end. Still, if you find multiple assets with the same band names, there are still heuristics how you can go ahead with it and use the metadata to hopefully figure out which to choose (e.g. based on the resolution). The fallback can always be to let users pick asset keys. |
I do think the goal of the python client should be to detect the band names as described in the collection (otherwise requiring to load in specific items to determine those), and it should be the responsibility of the collection providers to provide a correct bands overview. However I also think we should be lax in what we accept as input, so the scope of this issue is to allow a fallback on using the bands that the user specified in |
yes I'm fine with being lenient about this (e.g. warnings instead of exceptions) as long as we're still figuring out how to pragmatically cover various STAC use cases in the wild |
closing this one already as #755 was just merged |
if
metadata_from_stac()
can't find band names it creates a BandDimension without band labels. This empty bands dimension causes an error here:openeo-python-client/openeo/rest/datacube.py
Lines 431 to 435 in 9b92d6f
which in turns causes the metadata to be set to None.
A nicer way to threat this is to set the requested bands in load_stac as band labels if the python-client could not derive band names
Having metadata set to None instead of default dims causes an error in this sequence of processes:
The text was updated successfully, but these errors were encountered: