Open-EO / openeo-geopyspark-driver

OpenEO driver for GeoPySpark (Geotrellis)
Apache License 2.0
26 stars 4 forks source link

bands argument in `load_stac` leads to error after `aggregate_spatial` #873

Open VincentVerelst opened 1 week ago

VincentVerelst commented 1 week ago

I have a process graph in which I load in a STAC collection, filter on some bands, and then do spatial aggregation to extract some points:

...
s2_bands = [
    "S2-L2A-B01",
    "S2-L2A-B02",
    "S2-L2A-B03",
    "S2-L2A-B04",
    "S2-L2A-B05",
    "S2-L2A-B06",
    "S2-L2A-B07",
    "S2-L2A-B08",
    "S2-L2A-B8A",
    "S2-L2A-B11",
    "S2-L2A-B12"
]

cube = c.load_stac('/data/users/Public/vincent.verelst/world_cereal/s1_s2_meteo_extraction/Sentinel2/small-split-stac/collection-32736/collection.json', bands=s2_bands)

geometries = c.load_url('https://artifactory.vgt.vito.be/artifactory/auxdata-public/gfmap/32736-random-points.geoparquet', format='Parquet')

cube = cube.aggregate_spatial(geometries=geometries, reducer='mean')
...

This process graph gives the following error:

java.lang.IllegalArgumentException: Invalid band count, actual: 15, expected: 11

When I explicitly filter on bands using the filter_bands process, everything works as expected:

...
cube = c.load_stac('/data/users/Public/vincent.verelst/world_cereal/s1_s2_meteo_extraction/Sentinel2/small-split-stac/collection-32736/collection.json')
cube = cube.filter_bands(s2_bands)

geometries = c.load_url('https://artifactory.vgt.vito.be/artifactory/auxdata-public/gfmap/32736-random-points.geoparquet', format='Parquet')

cube = cube.aggregate_spatial(geometries=geometries, reducer='mean')
...