Ticket #3142 (closed defect: fixed)
Erroneous values in destination image with gdalwarp's interpolations
| Reported by: | andrieu | Owned by: | warmerdam |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.7.0 |
| Component: | Utilities | Version: | unspecified |
| Severity: | normal | Keywords: | gdalwarp interpolation |
| Cc: |
Description
Hello,
I have been trying to use gdalwarp to make some image merging and reprojection.
Unfortunately, with gdalwarp, the use of interpolations others than bilinear will produce images with wrong values.
My source pictures are Byte, 1 band, nodata = 0.
I have trying to use various destination datatype but they all lead to the same results : values in the destination image are below 0 (I even found a value around -80...) and so are considered as nodata.
My conversion script is :
gdal_translate -projwin 713676 4783608 713692 4783597 PIC_SS_P_821_8bit.tif little.tif gdalwarp -t_srs EPSG:4326 -r bilinear -ot Int32 -dstnodata -100 little.tif little_bilinear_1.tif gdalwarp -t_srs EPSG:4326 -r cubic -ot Int32 -dstnodata -100 little.tif little_cubic_1.tif gdalwarp -t_srs EPSG:4326 -r cubicspline -ot Int32 -dstnodata -100 little.tif little_cubicspline_1.tif gdalwarp -t_srs EPSG:4326 -r lanczos -ot Int32 -dstnodata -100 little.tif little_lanczos_1.tif
I then use a gdal_translate to add compression, tiling and correct nodata :
gdal_translate -ot Byte -a_nodata 0 -scale 0 255 1 255 -co TILED=YES -co COMPRESS=DEFLATE -co PREDICTOR=1 source dest
And finally a gdaladdo pass.
The reason I make a gdalwarp in a signed datatype is that the interpolation does not take the nodata value in consideration so my destination image will be filled with wrong nodata. So to avoid that, use of gdalwarp in signed datatype followed by a gdal_translate in unsigned datatype with scaling will produce correct nodata.
By the way, I am using FWTools 2.2.9 and 2.4.3 (same results).
This is very sad because image quality is better with lanczos than with bilinear...
Regards,
Benoit Andrieu

