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

Usage Question: Returning data in source pixel grid with no resampling #120

Open
pbranson opened this issue Jun 22, 2023 · 2 comments
Open

Comments

@pbranson
Copy link

Hi, thanks for the great library - it is really easy to work with.

I have a specific use case for analysing Sentinel 2 stacks, which are already rectified and referenced to a consistent grid across scenes. Is it possible to use odc stac to return the data where the coordinates for each pixel, across each band are the same as the source files?

Currently I am using bbox, but I am not sure if resampling is taking place.

Thanks

@Kirill888
Copy link
Member

The most precise mechanism for controlling output pixel grid is to use GeoBox, supplied via geobox= parameter to odc.stac.load(.., geobox=..).

If your STAC metadata contains necessary elements^^ AND all STAC items share "common pixel grid"**, odc-stac will default to loading pixels with the native grid and not resampling. In the general case "native load" is of course not possible, say when region spans UTM zones and you have S2 granules in different projections.

^^ basically Projection Extension Information, see STAC best practices
** common pixel grid means: same CRS, same resolution, same "grid anchor". For Sentinel 2 "grid anchor" is "pixel edge aligns to x=0, y=0lines when extending grid all the way to the origin, which is also default anchor inodc.stac.load` when generating.

So you might be already loading data in non-resampled way, since supplying bbox= applies this "pixel snapping", I still don't have a document to point people to for explaining exact pixel grid behaviours 😮‍💨

@Kirill888
Copy link
Member

You can construct GeoBox from bounding box using odc.geo.geobox.GeoBox.from_bbox, CRS and resolution is kinda obvious, anchor= is what you need to understand to create an appropriate GeoBox for your data, usually it's "edge aligns to X/Y axis" (Sentinel 2), other common one is "center aligns to X/Y axis" (Landsat, climate data often uses that too). And if you have other data already loaded you can just query the geobox of that data with xx.odc.geobox, and then use that directly or construct "compatible GeoBox" with GeoBox.enclosing method.

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