Open zdila opened 3 years ago
Just found out that tool ConvertNodataToZero also produces invalid result for the same input. So other tools may be affected as well.
I localized the problem to be -co PREDICTOR=2
:
Whitebox Tools produces bad result for GeoTIFF created like this:
gdalwarp -tr 64 64 -tap -r average -of GTiff -co TILED=YES -co BIGTIFF=YES -co COMPRESS=LZW -co PREDICTOR=2 -co NUM_THREADS=ALL_CPUS -wo NUM_THREADS=ALL_CPUS -multi dmr5.vrt scaled_64.tif
...but is OK with
gdalwarp -tr 64 64 -tap -r average -of GTiff -co TILED=YES -co BIGTIFF=YES -co COMPRESS=LZW -co NUM_THREADS=ALL_CPUS -wo NUM_THREADS=ALL_CPUS -multi dmr5.vrt scaled_64.tif
In #97 it was said by @jblindsay that the issue with PREDICTOR=2
should be fixed in release 1.3.1 ... but I can also confirm that neither 1.3.1 or 1.5.0 produces valid raster when the input uses PREDICTOR=2
(both DEFLATE
or LWZ
). However, using as input a raster with PREDICTOR=3
does show the error message The GeoTIFF reader does not currently support floating-point predictors (PREDICTOR=3).
I looked into this a bit more and it seems that the values inside data
are not stored properly even before entering the decoding predictor code part. The first value of each row (first column) is always the right one, but not the following as they are way too small (like 2.05e-38 instead of 5 for exemple...) and the last value of the last row is always -3.24e38. That is for a 32-bit float raster. I haven't yet tested other datatypes.
The math behind the predictor seems good when comparing with this random reference.
It boggles me that the same raster, with DELFATE compression but without predictor is read correctly...
Used whitebox-tools version: db8423fd1e9b884ab9c6cd11eff7309c1e892a0a
Command:
Input: https://drive.google.com/file/d/1LUw0YHwMV5RMFSOoy8trauhyVXBLK-mP/view?usp=sharing
Output: https://drive.google.com/file/d/1kXEpenEZB52myoyAYAT63AQ_sib75mTB/view?usp=sharing