-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
gdalwarp: add arbitrary percentile resampling (Pxx) #13613
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
base: master
Are you sure you want to change the base?
Conversation
| eResampleAlg = GRA_Percentile; | ||
|
|
||
| // Store percentile for warp kernel | ||
| CPLSetConfigOption("GDAL_WARP_PERCENTILE", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't do that way. Config options are global and messy to deal with. Ideally we would have some C structure describing more about resampling methods than just their identifier., but that would be a quite substantial change. The probably more reasonable way is to request than when GRA_Percentile is set a warping options passed through GDALWarpOperation::papszWarpOptions is specified
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I’ve updated the implementation to pass the percentile through papszWarpOptions (using a PERCENTILE warping option) instead of a global config option, and updated the warp kernel accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call to CPLSetConfigOption() should still be removed. I believe this function should likely take a CPLStringList& aosOptions output argument, and you would do aosOptions.SetNameValue("PERCENTILE", CPLString().Printf("%f", dfPercentile)). And you should "connect the dots" somewhere by actually adding the options filled by GDALGetWarpResampleAlg() to the papszWarpOptions used by gdalwarp_lib.cpp
Summary
This PR adds support for arbitrary percentile resampling to
gdalwarpand the warp kernel.
Users can now specify resampling methods such as
-r P95,-r P50, etc.,generalizing the existing quartile and median logic (
q1,med,q3).Initial support is limited to the warp code path (
gdalwarp/ rasterreprojection). Resize and overview support can be added in follow-up work.
Details
GRA_Percentileresampling algorithmGDALGetWarpResampleAlg()to parsePxxvaluesGWKAverageOrModeThread()P50 ≡ med,P25 ≡ q1,P75 ≡ q3P95)P0,P100)Tests
Added tests to
autotest/utilities/test_gdalwarp.py.All existing tests pass.
Notes
Design discussion referenced: warp-only support first, with possible
extension to resize / overviews later.