Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grid Polygons slightly offset from the images #15

Open
uceshaf opened this issue Jan 6, 2025 · 2 comments
Open

Grid Polygons slightly offset from the images #15

uceshaf opened this issue Jan 6, 2025 · 2 comments

Comments

@uceshaf
Copy link

uceshaf commented Jan 6, 2025

Hi, thanks for the dataset and especially the creation of major-tom grid.

I am using the grid.py code to generate the grid for 10km distance and a 0.034 buffer_ratio to get polygons matching with the extents of the sentinel-2 tiles of 1068*1068 pixels. The bottom-left points of the grid polygons match perfectly with the Sentinel-2 tile corners, the rest of the image appears to be slightly slanted, causing the other corners to misalign with the grid polygons.
I have tried exporting footprints for each UTM zone separately in its own crs and then compare to the tile outlines.

image
image

Am I misunderstanding something about grid generation or buffer ratio? Is there some approach to derive exact footprints of Sentinel-2 tiles without downloading the dataset?

Thanks for any guidance or clarification on this.

@mikonvergence
Copy link
Collaborator

Hi @uceshaf - thanks for the kind words!

generate the grid for 10km distance and a 0.034 buffer_ratio to get polygons matching with the extents of the sentinel-2 tiles of 1068*1068 pixels

So this is the confusing part I think. We use a MT grid of 10 km, and the buffer is only applied when extracting a sample. The buffer can only be added when the projection of the extracted raster is known. The grid object only defines a single point for each cell. The point corresponds to a single corner (bottom-left) of a Major TOM cell. Combined with the buffer size (340m) and cell size (10,680m), we can define the 4 corners of the extracted sample footprint.

This notebook for extracting a Major TOM cell from an original Sentinel-2 product may be helpful:
https://github.com/ESA-PhiLab/Major-TOM/blob/main/MajorTOM/extras/extract-sample-from-raw-S2.ipynb

Since this seems to be a common practice, we could think of a way of integrating this functionality into the package in a more transparent way and making it easier to start using.

@uceshaf
Copy link
Author

uceshaf commented Jan 7, 2025

Hi, thanks for your response!

Thanks for the clarification regarding the grid and buffer. I was able to generate the raster outline shapefiles for each UTM zone and globally, which match with the actual outlines of the sample images.

To facilitate the "integrating this functionality into the package in a more transparent and user-friendly way", I have shared the updated version of the grid.py file and a demo notebook grid_functionality_demo.ipynb illustrating the process

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants