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

[BUG] EO extension get_bands on a non-EO asset returns Item bands #404

Closed
emmanuelmathot opened this issue Jun 3, 2021 · 2 comments · Fixed by #406
Closed

[BUG] EO extension get_bands on a non-EO asset returns Item bands #404

emmanuelmathot opened this issue Jun 3, 2021 · 2 comments · Fixed by #406

Comments

@emmanuelmathot
Copy link
Contributor

Expected Behavior

When using EOExtension.ext(asset).bands on an asset that has no bands, it must return None.

Current Behavior

When using EOExtension.ext(asset).bands on an asset that has no bands, it may return all Item bands if declared at Item level

Identified issue

get_bands method in EOExtension uses PropertiesExtension._get_property that extends the retrieval to the asset's parent Item.

Possible Solution

change the _get_property method with a simpler get in asset properties only.

Steps to Reproduce

item = pystac.Item.from_file("https://gist.githubusercontent.com/emmanuelmathot/00e8738216f4a359a42b25ea2ca56271/raw/309ee298080978c692fa729a2ba589f95bfacb1c/S2A_MSIL1C_20200615T060641_N0209_R134_T45WWS_20200615T080720.json")
for key, asset in item.get_assets().items():
    eo_bands = EOExtension.ext(asset).bands
    if (key == "mtd"):
        assert eo_bands is None

Context (Environment)

  • python 3.8
  • pystac 1.0.0-beta.3

As defined in https://github.com/stac-extensions/eo/:

The eo:bands array may optionally be used in the Item Properties to summarize the available bands in the assets. This should be a 'union' of all the possible bands represented in assets. It should be considered merely informative - clients should rely on the eo:bands of each asset.

@duckontheweb
Copy link
Contributor

It seems like this was the intended behavior of the PropertiesExtension, but I agree that it constitutes a bug in this case. I'm wondering if there are any specific extensions where this would be the expected behavior. If not, we may want to change this at the PropertiesExtension level instead of just for the EO Extension.

@lossyrob may have more insight into the original intention.

@emmanuelmathot emmanuelmathot changed the title [BUG] EO extension get_bands on a non-EO returns Item bands [BUG] EO extension get_bands on a non-EO asset returns Item bands Jun 4, 2021
@emmanuelmathot
Copy link
Contributor Author

Indeed, this is a intended behavior for properties like eo:cloud_cover or gsd. That's why I proposed a fix for the eo:bands field only in AssetEOExtension

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