Nearest-Neighnors resampling of 20m bands in SENTINEL2_L2A and SENTINEL2_L2A_SENTINELHUB?

Dear all,

It seems that both SENTINEL2_L2A and SENTINEL2_L2A_SENTINELHUB collections have nearest neighbors interpolation of 20m bands to 10m. It looks like the processor that produces the data (Sentinel-2 L2A ) supports better resampling options (namely BICUBIC), but I do not know how to ask OpenEO to use BICUBIC resampling when loading the collection. Is this even possible ?

Many thanks,

Julien

Hi Julien,

It should be possible to use resample_spatial to change the resampling method of the datacube:

cube = c.load_collection("SENTINEL2_L2A")
cube = cube.resample_spatial(resolution=10, method="cubicspline")
cube.download("output.nc")

If that doesn’t work, you can always create a separate cube for the 20m bands, resample them to 10m, and then merge them with with the other bands:

cube_20m = c.load_collection("SENTINEL2_L2A", bands=["B05"])
cube_10m = c.load_collection("SENTINEL2_L2A", bands=["B01"])
cube_20m = cube_20m.resample_spatial(resolution=10, method="cubicspline")
cube = cube_20m.merge_cubes(cube_10m)
cube.download("output_merged.nc"

Hope that helps!

The documentation for resample_spatial shows which methods are supported:
https://processes.openeo.org/#resample_spatial
https://processes.openeo.org/#merge_cubes

Hi Jeroen, and thanks for your suggestions,

I tried both, and unfortunately none of these works because it seems that 20m data are already resampled at 10m using nearest neigthbors in load_collection. Any subsequent resampling starts from those poorly resampled 10m data.

Regards,

Julien

Hi Julien,

This is something that I will have to look at more closely. Does this issue take precedence over the overlap issue you have with the super-resolution example, or should that issue be resolved first?

I did notice that these two code samples provide two different outputs, even though both are 10m resolution:

import openeo
connection = openeo.connect("openeo.vito.be").authenticate_oidc()
cube = connection.load_collection(
    "SENTINEL2_L2A",
    spatial_extent={"west": 3.75, "east": 3.76, "south": 51.29, "north": 51.30},
    temporal_extent=["2017-03-05", "2017-03-10"],
    bands=["B01"],
)
cube.download("output_nearestneighbour.nc")
import openeo
connection = openeo.connect("openeo.vito.be").authenticate_oidc()
cube = connection.load_collection(
    "SENTINEL2_L2A",
    spatial_extent={"west": 3.75, "east": 3.76, "south": 51.29, "north": 51.30},
    temporal_extent=["2017-03-05", "2017-03-10"],
    bands=["B01"],
)
cube = cube.resample_spatial(resolution=10, method="cubicspline")
cube.download("output_cubespline.nc")

Hi Jeroen,

Actually, I tested it on the SENTINEL2_L2A_SENTINELHUB collection, and there is no differences between with or without call to resample_spatial. But when using the SENTINEL2_L2A there is indeed a difference and the 20m data are correctly resampled to 10m with bicubic, so I can stick with this collection for now.

I believe that the SentinelHub API allows to choose the resampling algorithm but the default value is set to NEAREST. If we could provide additional options to load_collection maybe it would allow to workaround this case.

Thanks a lot,

Julien