Skip to content
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

Indexing Sentinel S2 Level-2A dataset: KeyError: 'sentinel:latitude_band' #64

Open
pierocampa opened this issue Aug 4, 2023 · 1 comment

Comments

@pierocampa
Copy link

Before the server upgraded the STAC version to 1.0.0-beta.2, I was able to successfully load the following Sentinel Level-2A time-series from the online earth-search.aws.element84.com/v0/ catalogue into my ODC:

$ stac-to-dc \
    --bbox='11,45,12,46' \
    --catalog-href='https://earth-search.aws.element84.com/v0/' \
    --collections='sentinel-s2-l2a-cogs' \
    --datetime='2015-06-01/2023-07-01'" 

Now I get the following error which inhibits the successful

pystac_client.warnings.DoesNotConformTo: Server does not conform to ITEM_SEARCH, There is not fallback option available for search.

Using the alternative catalogue from earth-search.aws.element84.com/v1/ with STAC 1.0.0, and switching to the available S2 Level-2A collection "sentinel-2-l2a":

$ stac-to-dc \
    --bbox='11,45,12,46' \
    --catalog-href='https://earth-search.aws.element84.com/v1/' \
    --collections='sentinel-2-l2a' \
    --datetime='2015-06-01/2023-07-01'" 

Now I get the error in the title of this issue:

08/04/2023 03:30:12: ERROR: Failed to handle item S2A_32TPQ_20161105_0_L2A with exception 'sentinel:latitude_band'
...
  File "/usr/local/lib/python3.10/site-packages/odc/apps/dc_tools/_stac.py", line 96, in _stac_product_lookup
    properties["sentinel:latitude_band"],
KeyError: 'sentinel:latitude_band'

Indeed, it should look (in this case) into "mgrs:latitude_band" (and "mgrs:grid_square") properties:

            if region_code is None:
                # Let this throw an exception if there's something missing
                region_code = "{}{}{}".format(
                    str(properties["proj:epsg"])[-2:],
+++                 properties["mgrs:latitude_band"],
+++                 properties["mgrs:grid_square"],
---                 properties["sentinel:latitude_band"],
---                 properties["sentinel:grid_square"],

If I correct this part, I then also get other problems due to assumptions on the name of the bands:

odc.apps.dc_tools.utils.IndexingException: Failed to create dataset with error The dataset is not specifying all of the measurements in this product.
Missing fields are;
{'B02', 'B01', 'B8A', 'B07', 'B03', 'B04', 'B09', 'AOT', 'WVP', 'B08', 'B11', 'SCL', 'B05', 'B12', 'B06'}
 The URI was s3://sentinel-cogs/sentinel-s2-l2a-cogs/32/T/QS/2023/6/S2B_32TQS_20230627_0_L2A/S2B_32TQS_20230627_0_L2A.json

Indeed there's no such field in the items; e.g: earth-search.aws.element84.com/v1/collections/sentinel-2-l2a/items/S2B_38XNJ_20230804_0_L2A.

Is this a catalogue error or too many assumptions made by dc_tools?
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants