Open-EO / openeo-geotrellis-extensions

Java/Scala extensions for Geotrellis, for use with OpenEO GeoPySpark backend.
Apache License 2.0
5 stars 3 forks source link

Combining these gives an error: all & not_ & date_between #286

Open EmileSonneveld opened 2 months ago

EmileSonneveld commented 2 months ago
begin_date = "2020-01-01"
end_date = "2020-01-10"
dates_to_remove = ["2020-01-04", "2020-01-05", "2020-01-06", "2020-01-08"]  # Example dates to remove

bbox = [5.0, 51.2, 5.1, 51.3]

s2_bands = eoconn.load_collection(
    "SENTINEL2_L2A",
    temporal_extent=[begin_date, end_date],
    spatial_extent=dict(zip(["west", "south", "east", "north"], bbox)),
    bands=["B04", "B08"],
    max_cloud_cover=20,
)

condition = lambda x: eop.all(
    [
        eop.not_(
            x = eop.date_between(
                x=x,
                min=f"{timestep}T00:00:00Z",
                max=eop.date_shift(date=f"{timestep}T00:00:00Z", value=1, unit='day')
            )  
        )

        for timestep in dates_to_remove

    ]
)

s2_bands = s2_bands.filter_labels(condition=condition, dimension="t")
s2_bands.execute_batch()

Error: [500] Internal: Server error: java.lang.ClassCastException: class java.time.ZonedDateTime cannot be cast to class scala.collection.Seq (java.time.ZonedDateTime is in module java.base of loader 'bootstrap'; scala.collection.Seq is in unnamed module of loader 'app') (ref: r-240424fdf86e43d6afa509d56fc58bb3)

cc @HansVRP

EmileSonneveld commented 2 months ago

A workaround is to invert the date intervals, to avoid using not_