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

Issue567 stac metadata temporal dim #591

Closed clausmichele closed 3 months ago

clausmichele commented 4 months ago

Very simple fix to https://github.com/Open-EO/openeo-python-client/issues/567, which allows doing:

from openeo.local import LocalConnection
local_conn = LocalConnection("./")

url = "https://stac.eurac.edu/collections/SENTINEL2_L2A_SAMPLE_2"
spatial_extent =  {"east": 11.40, "north": 46.52, "south": 46.46, "west": 11.25}
temporal_extent = ["2022-06-01", "2022-06-30"]
bands = ["B04"]
s2_cube = local_conn.load_stac(
    url=url,
    spatial_extent=spatial_extent,
    temporal_extent=temporal_extent,
    bands=bands,
)
s2_cube = s2_cube.reduce_dimension(dimension="time",reducer="mean")
s2_cube

which otherwise would end up with:

ValueError: Invalid dimension 'time'. Should be one of ['bands', 't']

clausmichele commented 4 months ago

@soxofaan I solved the mentioned issues!

clausmichele commented 4 months ago

@soxofaan the tests are passing, it's a bit more cumbersome to keep the support for the old Python versions though.

clausmichele commented 3 months ago

I would have some more updates to parse correctly the spatial and bands dimension names, should I include them here @soxofaan ?

soxofaan commented 3 months ago

I would have some more updates to parse correctly the spatial and bands dimension names, should I include them here ?

no, I would do that in a separate PR, otherwise we won't get this PR merged

soxofaan commented 3 months ago

I'll do some quick tweaks to this PR and try to merge asap

soxofaan commented 3 months ago

finetuned and merged in 35b5fc7b0cc844bf5f02b0e437f683f501ffe5ff

soxofaan commented 3 months ago

thanks!