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

Image-shifts through bbox, filter_spatial, or spatial_extent #69

Closed
cajmdebie opened this issue Aug 3, 2022 · 4 comments
Closed

Image-shifts through bbox, filter_spatial, or spatial_extent #69

cajmdebie opened this issue Aug 3, 2022 · 4 comments
Assignees

Comments

@cajmdebie
Copy link

When applying through OPENEO bbox, filter_spatial, or spatial_extent, the most top-left selected pixel (of 1km and 300m imagery!) shifts to the edge of the specified box or defined spacial extent. When extracting using OPENEO an area-of-interest, selected pixcels MUST however actually remain exactly where they were originally placed. When defining a boundary that coincides with pixel-centroids, that always leads to half a pixel shift while the user cannot predict what the first top-left pixel will be (there are 4 candidates!!). See below an example of a half-pixel (500m!!!) shift:

Clip1

@jdries jdries self-assigned this Sep 1, 2022
@cajmdebie
Copy link
Author

At 16Dec my findings remain:

Data example of two extents, where the center-of-pixel of a 1km top-left pixel = 25.000000, -15.383929

A. Use exact corner-of-corners of required pixels:

{'east': 33.29910714314813,
'west': 24.995535714565385,
'north': -15.379464285692597,
'south': -22.64732142854809}

B. Use with half a 333m pixel (0.5/336) extra window-size on all sides:
{'east': 33.30059523838622,
'west': 24.99404761932729,
'north': -15.377976190454502,
'south': -22.648809523786184}

Then the Corner-of-Corner of the top-left-pixel becomes:
Result A: 24.99553571, -15.37946429 <---- correct placing of top-left pixel
Result B: 24.99404762, -15.37797619 <---- image has indeed shifted 0.5/336 degrees!

and the Center-of-Pixel of the top-left-pixel becomes:
Result A: 25.00000000, -15.38392857 <---- correct placing of top-left pixel
Result B: 24.99851191, -15.38244048 <---- image has indeed shifted 0.5/336 degrees

@jdries
Copy link
Contributor

jdries commented Jan 27, 2023

Also happens with worldcover. Proposed solution: if datacube extension has the extent set, and the target crs is the same as source crs, we can try to align the user-provided extent to the one of the dataset.
This approach only works if the collection does not mix resolutions, or is in UTM.

jdries added a commit to Open-EO/openeo-python-driver that referenced this issue Feb 9, 2023
@jdries
Copy link
Contributor

jdries commented Feb 10, 2023

weird, seems like this one got closed automaticaly by a github bot?!
Anyway, I'm actively testing a solution.

@jdries jdries reopened this Feb 10, 2023
jdries added a commit to Open-EO/openeo-python-driver that referenced this issue Feb 10, 2023
jdries added a commit to Open-EO/openeo-python-driver that referenced this issue Feb 10, 2023
jdries added a commit that referenced this issue Feb 12, 2023
jdries added a commit that referenced this issue Feb 13, 2023
…the incoming extent, reduces special cases
jdries added a commit that referenced this issue Feb 13, 2023
* apply global_bounds also when not in utm projection
* do not apply rounding to resolution as a general rule, stick to globalbounds which is assumed to be rounded already if needed
* also skip resampling for layers that are not utm, all raster sources should be pre-aligned to layout
* align extent to layout before loading data
* further apply principle of always aligning raster sources to the incoming extent, reduces special cases
* update agera5 and dem tests, output has improved thanks to changes
@jdries
Copy link
Contributor

jdries commented Mar 6, 2023

I now fixed a lot of metadata to enable the feature that should improve the alignment, will appear on openeo-dev soon. Closing this one already, to reopen if still seeing the issues in a few days.

@jdries jdries closed this as completed Mar 6, 2023
@jdries jdries added this to the sap05-usability milestone Apr 17, 2023
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