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

S1+S2 composite merge: first value missing #135

Closed jdries closed 1 year ago

jdries commented 1 year ago

A complex combination leads to a datacube where the first S2 image in the timeseries is nodata:


  bands = vito_connection.load_collection(
        "TERRASCOPE_S2_TOC_V2",
        bands=["B02"],
        spatial_extent=EXTENT,
        temporal_extent=[STARTDATE, ENDDATE],
        max_cloud_cover=95
    )

    bands = bands.aggregate_temporal_period(period="dekad", reducer="mean")

    S1bands = vito_connection.load_collection(
        'SENTINEL1_GRD_SIGMA0',
        bands=['VH'],
        spatial_extent=EXTENT,
        temporal_extent=[STARTDATE, ENDDATE],
        properties= {"orbitDirection": lambda orbdir: orbdir == "ASCENDING"}
    )

    S1bands = S1bands.aggregate_temporal_period(period="dekad",reducer="mean")

    cube = bands.merge_cubes(S1bands)

    cube.execute_batch("sar_s2_orbit_asc.nc")
jdries commented 1 year ago

Sentinel 2 cube logging:

Created cube for urn:eop:VITO:TERRASCOPE_S2_TOC_V2 with metadata TileLayerMetadata(int16ud32767,LayoutDefinition(Extent(652910.0, 5679370.0, 655470.0, 5681930.0),CellSize(10.0,10.0),2x2 tiles,256x256 pixels),Extent(652915.9230789405, 5680678.468706609, 654568.4352774331, 5681921.294014332),EPSG:32631,KeyBounds(SpaceTimeKey(0,0,1614556800000),SpaceTimeKey(1,0,1635465600000))) and partitioner Some(SpacePartitioner(KeyBounds(SpaceTimeKey(0,0,1614556800000),SpaceTimeKey(1,0,1635465600000))))

Cube partitioner index: SparseSpaceTimePartitioner 54 false

aggregate_temporal results in 48 keys, using partitioner index: org.openeo.geotrelliscommon.package$SpaceTimeByMonthPartitioner$@79c654b8

Created cube for urn:eop:VITO:CGS_S1_GRD_SIGMA0_L1 with metadata TileLayerMetadata(float32,LayoutDefinition(Extent(652910.0, 5679370.0, 655470.0, 5681930.0),CellSize(10.0,10.0),2x2 tiles,256x256 pixels),Extent(652915.9230789405, 5680678.468706609, 654568.4352774331, 5681921.294014332),EPSG:32631,KeyBounds(SpaceTimeKey(0,0,1614816000000),SpaceTimeKey(1,0,1635638400000))) and partitioner Some(SpacePartitioner(KeyBounds(SpaceTimeKey(0,0,1614816000000),SpaceTimeKey(1,0,1635638400000))))

Cube partitioner index: SparseSpaceTimePartitioner 41 false

aggregate_temporal results in 48 keys, using partitioner index: org.openeo.geotrelliscommon.package$SpaceTimeByMonthPartitioner$@79c654b8

Merging cubes with spatial indices: org.openeo.geotrelliscommon.package$SpaceTimeByMonthPartitioner$@79c654b8 - org.openeo.geotrelliscommon.package$SpaceTimeByMonthPartitioner$@79c654b8

jdries commented 1 year ago

Fixes committed and reproduced in unit test. The partitioner keybounds was set incorrectly by aggregate_temporal in the particular case where the target label bounds exceeded the bounds of the original cube. My hypothesis is that the incorrect bounds then caused a mismatch in the partitions themselves, and the join based on SpacePartitioner to be incorrect.