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

Native resampling #837

Open
asinghvi17 opened this issue Dec 15, 2024 · 1 comment
Open

Native resampling #837

asinghvi17 opened this issue Dec 15, 2024 · 1 comment
Labels
bug Something isn't working enhancement New feature or request needs thought performance

Comments

@asinghvi17
Copy link
Collaborator

asinghvi17 commented Dec 15, 2024

It seems that with Interpolations.jl and Proj.jl, we can already get native resampling pretty easily using Images.jl's inverse warp functionality. This is only doable if we have a known desired output grid for now, but automatic grid generation doesn't seem like that much of a challenge.

But one thing I've been wondering about is how we would treat the sum, quartile, etc methods of resampling.

I looked into the GDAL code and it looks like they approximate grid cells as quadrilaterals, and then perform intersections between the source and target grids. Basically, you take the grid points in target space, project them back to source space, and perform an intersection-area-weighted-operation on each target grid cell in source space. The GDAL source code is linked here, where you can see what they are doing.

See the graphic below for what the (smooth) projected grid lines look like in target space:
display

We could even go a step beyond GDAL in correctness (as a stretch goal) and offer subsampled sum/mean/median/etc via OnlineStats and GeometryOps. The effect is probably minimal but may be worth considering for some cases.

But we could even use GDAL's quadrilateral approximation. The only issue is that GDAL's discontinuity handling is fairly complicated, we probably don't want to reimplement that :D

@asinghvi17 asinghvi17 added the bug Something isn't working label Dec 15, 2024
@rafaqz
Copy link
Owner

rafaqz commented Dec 15, 2024

Cool yes I guess using Proj we can get rid of GDAL :)

GDAL seems to have a lot of options for the method though. And yes likely it's the decade or two of fixing edge cases that will be hard to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request needs thought performance
Projects
None yet
Development

No branches or pull requests

2 participants