A little bit of Context:
ESA is distributing [Sentinel 2]( Sentinel-2 - Missions - Sentinel Online - Sentinel (esa.int)) A/B at level-1C (Top Of Atmosphere) and L2A (Bottom Of Atmosphere) through tiles of fixed size. These cover an area of 100x100 km and are orthorectified-images in MGRS/WGS84 reference system.
For historical reasons, each tile has an overlapping area with around tiles. Unfortunately, overlaps are not fixed in dimension and vary according to the tile position within the reference grid. Within the metadata, there isn’t any information about the surrounding tiles.
The classic approach:
As most of the time, a single tile doesn’t cover the area of interest, mosaicking of the tiles is needed. Different approaches can be taken on how overlapping values are treated. Min, max, average, first, last are the most common according to the needs but much more complicate algorithms are available for specific cases.
In Rasterio, this can be easily obtained through the .merge module. To have a quick example of how ti is used, have a look here
From my understanding seems that there is no way to achieve the merging for one specific reason. Combine can’t be used as coordinates are not monotonic. Moreover, there isn’t an option to manage the overlapping pixels, but that would be the second step once the coordinate grid is determined. Here a discussion on this topic [Xarray combine_by_coords return the monotonic global index error]( Xarray combine_by_coords return the monotonic global index error · Issue #4213 · pydata/xarray (github.com))
For those interested in why this problem seems to be not present in the AWS, what I can say is that it seems that Sinergise, for the AWS service, has converted the files from jpeg2000 to tif, making some adjustments. Unfortunatelly I don’t have direct access to the AWS and can’t check by my self, but picking some info here and there seems that they used the average algorithm. This specific approach could be considered acceptable for the L1C but not for the L2A. But this is a completely different topic, and I would not investigate more for the moment.
Does anyone has stumbled with this problem? How did you solve it? It could be that I’m not aware of the specific module that can solve this. I’ve searched a little bit, but nothing has popped up.
Any idea about how I could organise a workaround in a ‘lazy dask’ approach?
It would be feasible to think of implementation in Xarray of a system to treat this specific problem.