Filter_spatial create datacubes which are wider than the input polygons

Hi all,
I want to create a Sentinel 2 Satellite Image Time Series on 30 different polygons described by a geojson. Each of the polygon belong to the same S2 tile and have the following dimension: 1280m*1280m. They were generated in the corresponding S2 tile UTM coordinate, then converted WGS 84.
To extract only time series on those defined polygons, I am using the function filter_spatial. The full code is given here:

import json
from pathlib import Path

import openeo
if __name__=="__main__":

    temporal_extent=TIMERANGE = ["2020-01-01", "2020-02-27"]
    OUTDIR = Path("/home/dumeuri/Documents/dataset/MMDC_OE")
    S2_BANDS = [
    "B02",
    "B03",
    "B04"
]
    if temporal_extent is None:
        temporal_extent = TIMERANGE

    connection = openeo.connect("openeo.cloud")
    connection.authenticate_oidc()
    sentinel2 = connection.load_collection(
    "SENTINEL2_L2A_SENTINELHUB", temporal_extent=temporal_extent, bands=S2_BANDS
)

    features="/home/dumeuri/Documents/dataset/datacubes/geojson/pretrain_val_31TEK.geojson"
    with open(features) as feat:
        print(feat)
        features = json.load(feat)
    datacube = sentinel2.filter_spatial(features)
    job = datacube.create_job(
            title="S2_minimal_T31TEK",
            description="S2_minimal_T31TEK",
            out_format="netCDF",
            sample_by_feature=True
        )
    job.start_job()

I can also share the geojson file used if needed. The id of the job which has executed this code is: vito-j-f5f0d0cbdf5845649e392177b0261d5b

However, when I download the generated datacubes, I observe that the extent of the different Satellite Image Time Series (SITS) are wider than the polygons given. More precisely, outside the defined polygon, the Satellite Image Time Series is filled with no data. The following image displays the issue. In the image given below : in yellow the given polygon in the geojson file, outside the polygon the black color corresponds to no-data. In this example, contrary to expectations, the SITS is not 128pix128pix but 256pix512pix.


It should be noted that the extent is not always the same for the different polygons, I have observed for instance 256pix512pix, 512pix512pix, 256pix*256pix.
Therefore, I am wondering if I have misunderstood filter_spatial function. And is there another function which could enable me to crop the final SITS on the given polygon ?
Best regards,
Iris

Hi Iris,
my apologies for the late reply, I think what you are doing is correct, so we need to check a bit deeper if something’s wrong. Unfortunately, we didn’t get to it this week yet, hope to get back to you soon!

best regards,
Jeroen

Hi Iris,
after investigation, it turns out that for cubes with a time dimension, the cropping to feature bounds was indeed missing, I now added this, so that it’s the same behavior as without time dimension.

The fix still needs to be tested, should we assume you are blocked by this (and try to roll out fast)?

Thank you very much for your answer. I have currently done a quick fix, by clipping the data to the correct geometry after downloading them. I am interested in this fix, but it is not a blocking point.
Best regards,
Iris

Hi Iris,
The issue has been fixed and is currently live on the openeo-dev.vito.be backend.

Best regards,
Jeroen

1 Like