<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><br>Hi,<div>Just to close this thread, this is the answer I got from Even Rouault on the gdal dev mailing list.</div><div><br></div><div><br></div><div><div style="caret-color: rgb(0, 0, 0); -webkit-text-size-adjust: auto; padding: 14px 0px 0px;"><blockquote type="cite" __apple_fixed_attribute="true"><font color="#000000">On mercredi 2 décembre 2020 15:16:44 CET Nicolas Cadieux wrote:<br></font></blockquote><blockquote type="cite"><font color="#000000">Hi,<br></font></blockquote><blockquote type="cite"><font color="#000000"><br></font></blockquote><blockquote type="cite"><font color="#000000">This follows a discussion in the qgis-user mailing list.  We are using<br></font></blockquote><blockquote type="cite"><font color="#000000">gdal_translate (and QGIS "export as") on a 8bit unsigned single band<br></font></blockquote><blockquote type="cite"><font color="#000000">tiff to a .gpkg.  When using no -ot switch or when using -ot Byte, this<br></font></blockquote><blockquote type="cite"><font color="#000000">results in a 4 band .gpkg raster with the wrong values.  (Values in band<br></font></blockquote><blockquote type="cite"><font color="#000000">1 to 3 are similar but off the mark). Band 4 is set at 255 as expected. <br></font></blockquote><blockquote type="cite"><font color="#000000">Looks like some type of compression is going on in the band 1 to 3).<br></font></blockquote><blockquote type="cite"><font color="#000000"><br></font></blockquote><blockquote type="cite"><font color="#000000">When saving using the -ot Int16 or Float32 switch, all is well and the<br></font></blockquote><blockquote type="cite"><font color="#000000">result has one band with the correct values.<br></font></blockquote><blockquote type="cite"><font color="#000000"><br></font></blockquote><blockquote type="cite"><font color="#000000">ex: gdal_translate -ot Int16 -of GPKG "E:/Users/Nicolas/Google Drive<br></font></blockquote><blockquote type="cite"><font color="#000000">Nicolas/Partage_temporaire/qgis/int16.gpkg" "E:/Users/Nicolas/Google<br></font></blockquote><blockquote type="cite"><font color="#000000">Drive Nicolas/Partage_temporaire/qgis/int16.gpkg"<br></font></blockquote><blockquote type="cite"><font color="#000000"><br></font></blockquote><blockquote type="cite"><font color="#000000">Is this a possible problem with the driver or is the problem sitting 18<br></font></blockquote><blockquote type="cite"><font color="#000000">inches in front of the screen? Problem similar on a Mac running QGIS<br></font></blockquote><blockquote type="cite"><font color="#000000">3.10.1-A with GDAL 3.0.2 and QGIS3.16 on Windows running GDAL 3.1.4.<br></font></blockquote><blockquote type="cite"><font color="#000000"><br></font></blockquote><blockquote type="cite"><font color="#000000">Test files are found here:<br></font></blockquote><blockquote type="cite"><font color="#000000"><a href="https://drive.google.com/drive/folders/1fMl9odowUFFRQFK61rTxgHeom_D8ymN6?usp" dir="ltr" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="1">https://drive.google.com/drive/folders/1fMl9odowUFFRQFK61rTxgHeom_D8ymN6?usp</a><br></font></blockquote><blockquote type="cite"><font color="#000000">=sharing</font><br></blockquote><blockquote type="cite"><font color="#ffffff"><br></font></blockquote><span style="caret-color: rgb(255, 255, 255);"></span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">The answer is there:</span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);"><a href="https://gdal.org/drivers/raster/gpkg.html#tile-formats" dir="ltr" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="2">https://gdal.org/drivers/raster/gpkg.html#tile-formats</a></span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);"></span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">For Byte input (that isn't recognized as to be used by the tiled gridded </span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">coverage data), the default tile format will use JPEG lossy compression for </span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">tiles with a fully opaque channel.</span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);"></span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">-co TILE_FORMAT=PNG will use lossless compression</span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);"></span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">GeoPackage raster aim was initially for visualisation purposes, hence this </span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">default. The more analytic side was a later addition to the format, and </span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">actually an extension</span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);"></span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">Even</span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);"></span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">-- </span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);">Spatialys - Geospatial professional services</span><br style="caret-color: rgb(255, 255, 255);"><span style="caret-color: rgb(255, 255, 255);"><a href="http://www.spatialys.com/" dir="ltr" x-apple-data-detectors="true" x-apple-data-detectors-type="link" x-apple-data-detectors-result="3">http://www.spatialys.com</a></span></div><div style="caret-color: rgb(0, 0, 0); -webkit-text-size-adjust: auto; padding: 14px 0px 0px;"><br></div><div dir="ltr"><br></div><div dir="ltr"><blockquote type="cite"><font color="#ffffff">Le 1 déc. 2020 à 09:58, Alberto Vavassori <alberto.vavassori@polimi.it> a écrit :<br><br></font></blockquote></div><blockquote type="cite"><div dir="ltr"><font color="#ffffff">

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
span.StileMessaggioDiPostaElettronica17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 2.0cm 2.0cm 2.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->


</font><div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt"><font color="#ffffff">Hello everybody. I have an issue regarding the Geopackage format. I have tried to import a singleband raster file (it represents the land cover, thus every pixel has a single integer value corresponding
 to the land cover class), but this operation seems to modify the raster characteristics: the raster becomes a 4-bands raster and the pixels values change accordingly (basically, the original raster is saved in the Geopackage as an RGB image). It seems to be
 a bug of QGIS. I have also tried to use GDAL translate through the processing toolbox of QGIS to convert the TIFF file to a Geopackage file, but the result is the same.<o:p></o:p></font></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt"><font color="#ffffff">Has anybody faced this problem? May anybody suggest a way to work this problem out?<o:p></o:p></font></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt"><font color="#ffffff">Thank you.<o:p></o:p></font></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt"><font color="#ffffff">Alberto<o:p></o:p></font></span></p>
</div>


<font color="#ffffff"><span>_______________________________________________</span><br><span>Qgis-user mailing list</span><br><span>Qgis-user@lists.osgeo.org</span><br><span>List info: https://lists.osgeo.org/mailman/listinfo/qgis-user</span><br><span>Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user</span></font><br></div></blockquote></div></body></html>