-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
OPTIMIZE_SIZE
Warper option from gdalwarp
gives different re-projection output
#10813
Comments
Yes
In theory yes, but in practice, this is hard to achieve. If your reprojection is relative uniform over the whole dataset (i.e. the ratio of source pixels needed to compute a target pixel) is approximately constant over it, you could specify "-wo XSCALE= -wo YSCALE=" to the gdalwarp command line. If you don't change resolution, the value would be 1. If you downsample by a factor of a half, that would be 0.5, etc. |
I know there is a Change in 3.8 that makes OPTIMIZE_SIZE to be auto enabled when needed so, just curious if there a specific reason for that ? Wondering if that can be default to FALSE again somehow? The reason being the other libs using gdal , i.e Or if there's way to define in the documentation that this option that is now defaults to True (when ever needed) can yield to different results so make sure to disable it if the olde results are needed? |
and document XSCALE and YSCALE warping options Ref #10813
yes, cf commit 9bd899a: "Warper: auto-enable OPTIMIZE_SIZE warping option when reasonable (fixes #7761)"
Not unless there would a major reason to do so, like bad results, very poor performance. Not just little pixel difference.
gdalwarp results shouldn't be expected to remain identical among GDAL (and PROJ) versions, due to various adjustments in heuristics, precision of computations, etc.
Here you are: #10814 |
Thanks @rouault . I think I got my answer and we are able to get the correct or can say previous expected results via the Thanks for all the explanations !! |
and document XSCALE and YSCALE warping options Ref #10813
and document XSCALE and YSCALE warping options Ref OSGeo#10813
and document XSCALE and YSCALE warping options Ref OSGeo#10813
and document XSCALE and YSCALE warping options Ref OSGeo#10813
What is the bug?
Recently we tried to upgrade the GDAL version in the docker container.
After upgrade of the GDAL from 3.5.3 to GDAL 3.9.1 we have found that one of the re-projection output was having differences (not in all pixels but kind of scan lines with slight pixel shift)
Verified that same shift happens in GDAL version 3.8
First we thought that it may be because of the
rasterio
as the issue was while using therio warp
but not withgdalwarp
so logged the issue / discussion inraserio
After discussion it was found that same issue haapens in
gdalwarp
if the-co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512
whichrio warp
is using by default.It turns out after so much trial and error that it was because of the one of the
warper option
OPTIMIZE_SIZE
that seems like before GDAL 3.8 was alwaysFALSE
for everything, But since GDAL 3.8 is automatically enabled (may be for TILED / BLOCKSIZE / Compressed options) when it is safe to do so, and that produces a slight pixel shift / difference in reprojected outputTesting the
gdalwarp
post GDAL 3.8 with that warper option disabled gives the same reprojected output as it was in older versions ofGDAL
Not sure if it is expected behavior but shouldn't the reprojected output be same with or without that
warper option
?Steps to reproduce the issue
Note: Reprojection is from UTM Zone 22N to Geographic (EPSG:4326)
Data Files
Tif file with no reprojection done (Currently in UTM Zone 22N). Providing the google drive link as can't upload more than 25 MB file
Run a docker container
Run GDAL WARP with different scenarios**
GDAL WARP - Non Tiled creation option with default Optimize Size
GDAL WARP - Non Tiled creation option with Optimize Size disabled
GDAL WARP - Non Tiled creation option with Optimize Size enabled
GDAL WARP - Tiled creation option with default Optimize Size
GDAL WARP - Tiled creation option with Optimize Size disabled
GDAL WARP - Tiled creation option with Optimize Size enabled
Differences
The output that ran with
-co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512
with DefaultOPTIMIZE_SIZE
that auto enables or withOPTIMIZE_SIZE
as TRUE differs from thegdalwarp
that didn't use the-co TILED=YES -co BLOCKXSIZE=512 -co BLOCKYSIZE=512
or used theOPTIMIZE_SIZE
as FALSEOpened the outputs from above re-projections in QGIS and ran the raster diff
Versions and provenance
Additional context
Same details discussed on the
rasterio
repo which may have some extra detailsThe text was updated successfully, but these errors were encountered: