Open-EO / openeo-earthengine-driver

openEO back-end driver for Google Earth Engine.
Apache License 2.0
21 stars 7 forks source link

merge_cubes with different dimensions (but overlapping x, y, t and bands) fails with server 500 error #68

Open Jaapel opened 2 years ago

Jaapel commented 2 years ago

When trying to merge 4 cubes over a short test time-period (see python client code example) I get OpenEoApiError: [500] Internal: Server error: Image.select: Parameter 'input' is required.

Clearly this calls the GEE backend in some way that was not expected. Am I missing something

from openeo import connect, Connection
from openeo.rest.datacube import DataCube
from typing import List, Dict, Tuple, Union
import pathlib

ee_url: str = "https://earthengine.openeo.org"
con: Connection = connect(ee_url).authenticate_basic(username="group1", password="test123")

out_dir = pathlib.Path("output")
out_dir.mkdir(parents=True, exist_ok=True)

# Get the collections needed
collections: List[Tuple[Union[str, List[str]]]] = [
        ('LANDSAT/LT4_L1T_TOA', ['B5', 'B2']),
        ('LANDSAT/LT5_L1T_TOA', ['B5', 'B2']),
        ('LANDSAT/LE7_L1T_TOA', ['B5', 'B2']),
        ('LANDSAT/LC8_L1T_TOA', ['B6', 'B3'])
    ]
# Define constraints for loading
spain_bounding_box: Dict[str, float] = {"west": -9.39288367353, "south": 35.946850084, "east": 3.03948408368, "north": 43.7483377142}
temporal_extent: List[str] = ["2021-04-26", "2021-04-30"]

combined_tiff_filename: str = "combined.tiff"

# Get and merge collections
for i, cl in enumerate(collections):
    if not collections: raise RuntimeError("please list wetness collection")
    dc: DataCube = con.load_collection(
        collection_id=cl[0],
        spatial_extent=spain_bounding_box,
        temporal_extent=temporal_extent,
        bands=cl[1]
    ).add_dimension(name="source_name", label=cl[0], type="other")  #TODO: add dimensional gives 500 error
    if i==0:
        combined_dc: DataCube = dc
    else:
        combined_dc: DataCube = combined_dc.merge_cubes(dc)

combined_dc.download(out_dir / combined_tiff_filename, format="GTIFF-THUMB")
Jaapel commented 2 years ago

@m-mohr Updated comment as I posted the unedited version by accident.

m-mohr commented 2 years ago

I'll try to look into this, but can't promise anything right now. This driver is mostly unmaintained, unfortunately, due to the lack of funding / interest from Google itself.

Jaapel commented 2 years ago

Good to know! And many thanks!

m-mohr commented 2 years ago

Had a quick look, but doesn't seem to be easy to fix. The colleagues from TU Vienna are not working on openEO any longer so I doubt this will receive a fix. The merge_cubes implementation seems pretty basic right now. I'm sorry about that.

Jaapel commented 2 years ago

Thanks for letting me know. I will have a look at alternatives 👍 .