[gdal-dev] gdal_translate, exporting "Byte - Eight bit unsigned integer" single band tiff to gpkg using -ot Byte results in 4 bands raster with changed values

Nicolas Cadieux njacadieux.gitlab at gmail.com
Wed Dec 2 12:16:44 PST 2020


Hi,

This follows a discussion in the qgis-user mailing list.  We are using 
gdal_translate (and QGIS "export as") on a 8bit unsigned single band 
tiff to a .gpkg.  When using no -ot switch or when using -ot Byte, this 
results in a 4 band .gpkg raster with the wrong values.  (Values in band 
1 to 3 are similar but off the mark). Band 4 is set at 255 as expected.  
Looks like some type of compression is going on in the band 1 to 3).

When saving using the -ot Int16 or Float32 switch, all is well and the 
result has one band with the correct values.

ex: gdal_translate -ot Int16 -of GPKG "E:/Users/Nicolas/Google Drive 
Nicolas/Partage_temporaire/qgis/int16.gpkg" "E:/Users/Nicolas/Google 
Drive Nicolas/Partage_temporaire/qgis/int16.gpkg"

Is this a possible problem with the driver or is the problem sitting 18 
inches in front of the screen? Problem similar on a Mac running QGIS 
3.10.1-A with GDAL 3.0.2 and QGIS3.16 on Windows running GDAL 3.1.4.

Test files are found here: 
https://drive.google.com/drive/folders/1fMl9odowUFFRQFK61rTxgHeom_D8ymN6?usp=sharing

Thanks!

Nicolas

Nicolas Cadieux
https://gitlab.com/njacadieux



More information about the gdal-dev mailing list