<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Nicolas:</p>
<p>I reached out to Alberto for the original data as the one on
google drive did not contain georeferencing and therefore would
not write to a geopackage. I tried to write the geopackafge from
Alberto's data and I generated 3 bands. I just got back from a
meeting and I will play with it some more.</p>
<p>Kirk<br>
</p>
<div class="moz-cite-prefix">On 12/2/2020 12:10 PM, Nicolas Cadieux
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:9CD357AB-BBDE-4594-9E1C-A2188B5226CC@gmail.com">Hi
Alberto,
<div><br>
<div>Can I share the file and your question in the gdal dev
group? Perhaps they will have an answer to your problem. You
can also do that yourself if you prefer.</div>
<div><br>
</div>
<div>Kirt, if you have time, can you do the same run with the
data in my google link? If you can’t duplicate the problem,
then we will have a better idea if you share your QGIS version
and OS. Perhaps there is change in the gdal version between
both computers.<br>
<br>
<div dir="ltr">Nicolas Cadieux
<div><a href="https://gitlab.com/njacadieux"
moz-do-not-send="true">https://gitlab.com/njacadieux</a></div>
</div>
<div dir="ltr"><br>
<blockquote type="cite">Le 2 déc. 2020 à 10:11, Alberto
Vavassori <a class="moz-txt-link-rfc2396E" href="mailto:alberto.vavassori@polimi.it"><alberto.vavassori@polimi.it></a> a écrit :<br>
<br>
</blockquote>
</div>
<blockquote type="cite">
<div dir="ltr">
<meta name="Generator" content="Microsoft Word 15
(filtered medium)">
<div class="WordSection1">
<p class="MsoNormal"><span>Hi Kirk,</span></p>
<p class="MsoNormal"><span lang="EN-US">I tried with
another raster file that represents a temperature
distribution (continuous values). In this case, when
I import it into the Geopackage, I see the same
issue that you have just described: minimum and
maximum values in the legend change, but it seems
that the actual values remain unchanged, thus
correct. Unfortunately this is not the case of the
land cover raster (discrete set of values) that I
have shared with you: in this case, the raster
characteristics change, as we have all noticed.</span></p>
<p class="MsoNormal"><span lang="EN-US">Just another
question, hoping that you might have an answer: is
it possible to store the symbology of a raster file
inside the Geopackage? I know that it is possible
for vector data, by clicking on “Style > Save
style” in the “Symbology” tab. But I cannot find a
way to save the symbology in case of raster files.</span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks a lot.</span></p>
<p class="MsoNormal"><span lang="EN-US">Alberto</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<div>
<div>
<p class="MsoNormal"><b>Da:</b> Qgis-user
<a class="moz-txt-link-rfc2396E" href="mailto:qgis-user-bounces@lists.osgeo.org"><qgis-user-bounces@lists.osgeo.org></a> <b>
Per conto di </b>Kirk Schmidt<br>
<b>Inviato:</b> mercoledì 2 dicembre 2020 16:00<br>
<b>A:</b> Nicolas Cadieux
<a class="moz-txt-link-rfc2396E" href="mailto:njacadieux.gitlab@gmail.com"><njacadieux.gitlab@gmail.com></a>;
<a class="moz-txt-link-abbreviated" href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a><br>
<b>Oggetto:</b> Re: [Qgis-user] R: Importing a
raster into a Geopackage</p>
</div>
</div>
<p class="MsoNormal"> </p>
<p>Hi all:</p>
<p>I ran the r.stats to get a list of each pixel value
on my test data (A small DEM) before and after
conversion to a geopackage (see second image below).
The values and summary stats are identical for the two
rasters but the default legend entry has a different
min and maximum value. So, I can conclude that the
data is being written correctly but the default
display parameters for the geopackage are different
than a geotiff.
</p>
<p>Kirk</p>
<p> </p>
<div><image001.png></div>
<div><image002.png></div>
<div>
<p class="MsoNormal">On 12/1/2020 3:24 PM, Nicolas
Cadieux wrote:</p>
</div>
<blockquote>
<p>Hi,</p>
<p>I changed the link so you have access to more
files.</p>
<p><a
href="https://drive.google.com/drive/folders/1fMl9odowUFFRQFK61rTxgHeom_D8ymN6?usp=sharing"
moz-do-not-send="true">https://drive.google.com/drive/folders/1fMl9odowUFFRQFK61rTxgHeom_D8ymN6?usp=sharing</a></p>
<p>Nicolas</p>
<div>
<p class="MsoNormal">On 2020-12-01 1:58 p.m., Kirk
Schmidt wrote:</p>
</div>
<blockquote>
<p>Hi Nicolas</p>
<p>I did the same and the legend indicates a change
magnitude but if I subtract the geopackage raster
from the original, all pixels equal zero.</p>
<p>Kirk</p>
<div>
<p class="MsoNormal">On 12/1/2020 2:36 PM, Nicolas
Cadieux wrote:</p>
</div>
<blockquote>
<p>Hi,</p>
<p>Tried this:</p>
<p>gdal_translate -of GPKG -b 1
C:/Users/Nicolas/Desktop/Land_cover_Corine2018.tif
C:/Users/Nicolas/Desktop/test.gpkg</p>
<p>I read 4 band and still get data modifications.</p>
<p>Nicolas</p>
<div>
<p class="MsoNormal">On 2020-12-01 1:28 p.m.,
Kirk Schmidt wrote:</p>
</div>
<blockquote>
<p>Hi Nicolas:</p>
<p>try the -b 1 parameter. I just tried this
and wrote a single band raster from a 3
channel tiff.</p>
<p>Kirk</p>
<div>
<p class="MsoNormal">On 12/1/2020 2:03 PM,
Nicolas Cadieux wrote:</p>
</div>
<blockquote>
<p>I tried </p>
<p>gdal_translate -of GPKG -co "BAND_COUNT=1"
C:/Users/Nicolas/Desktop/Land_cover_Corine2018.tif
C:/Users/Nicolas/Desktop/TEST.gpkg for the
creation and
</p>
<p>C:\>gdal_translate -of GPKG -co
"TILE_FORMAT = TIFF"
C:/Users/Nicolas/Desktop/Land_cover_Corine2018.tif
C:/Users/Nicolas/Desktop/TEST.gpkg</p>
<p>Same problem. I wonder if we need to
change the reading options... <a
href="https://gdal.org/drivers/raster/gpkg.html"
moz-do-not-send="true">
https://gdal.org/drivers/raster/gpkg.html</a></p>
<h2>"Opening options</h2>
<p>By default, the driver will expose a
GeoPackage dataset as a four band
(Red,Green, Blue,Alpha) dataset, which gives
the maximum compatibility with the various
encodings of tiles that can be stored. It is
possible to specify an explicit number of
bands with the BAND_COUNT opening option."</p>
<p>The problem could be when QGIS Reads the
file, not when it writes the file. I
explains why we see 4 bands but not why
values are changing. I would make a bug
report or ask the question on the gdal dev
group to get Even Rouault's attention.</p>
<p>Nicolas</p>
<p> </p>
<div>
<p class="MsoNormal">On 2020-12-01 12:17
p.m., Sebastian Gutwein wrote:</p>
</div>
<blockquote>
<div>
<p class="MsoNormal">This looks like the
same issue you are having. <a
href="http://github.com/qgis/QGIS/issues/38227"
moz-do-not-send="true">github.com/qgis/QGIS/issues/38227</a>
</p>
<div>
<p class="MsoNormal">According to the
documentation linked in the issue you
need to set the band count to 1
otherwise it defaults to 4. </p>
</div>
<div>
<p class="MsoNormal"><a
href="http://gdal.org/drivers/raster/gpkg.html"
moz-do-not-send="true">gdal.org/drivers/raster/gpkg.html</a></p>
</div>
<div>
<p class="MsoNormal">I have not tried
this to see if it works. </p>
</div>
</div>
<p class="MsoNormal"> </p>
<div>
<div>
<p class="MsoNormal">On Tue, Dec 1, 2020
at 11:52 AM Nicolas Cadieux <<a
href="mailto:njacadieux.gitlab@gmail.com"
moz-do-not-send="true">njacadieux.gitlab@gmail.com</a>>
wrote:</p>
</div>
<blockquote>
<div>
<p>Hi,</p>
<p>Looking at it now. I see what you
see. I will try a few things.</p>
<p>Nicolas</p>
<div>
<p class="MsoNormal">On 2020-12-01
11:42 a.m., Alberto Vavassori
wrote:</p>
</div>
<blockquote>
<div>
<p class="MsoNormal">Hi Nicolas,</p>
<p class="MsoNormal"><span
lang="EN-US">thank you for the
answer. I send the raster that
I am interested in.</span></p>
<p class="MsoNormal"><span
lang="EN-US">Alberto</span></p>
<p class="MsoNormal"><span
lang="EN-US"> </span></p>
<div>
<div>
<p class="MsoNormal"><b>Da:</b>
Nicolas Cadieux
<a
href="mailto:njacadieux.gitlab@gmail.com"
target="_blank"
moz-do-not-send="true"><njacadieux.gitlab@gmail.com></a>
<br>
<b>Inviato:</b> martedì 1
dicembre 2020 17:40<br>
<b>A:</b> Alberto Vavassori
<a
href="mailto:alberto.vavassori@polimi.it"
target="_blank"
moz-do-not-send="true">
<alberto.vavassori@polimi.it></a><br>
<b>Cc:</b> <a
href="mailto:qgis-user@lists.osgeo.org"
target="_blank"
moz-do-not-send="true">qgis-user@lists.osgeo.org</a><br>
<b>Oggetto:</b> Re:
[Qgis-user] Importing a
raster into a Geopackage</p>
</div>
</div>
<p class="MsoNormal"> </p>
<p>Hi,</p>
<p>Send a sample data set if you
can't figure it out.</p>
<p>Nicolas</p>
<div>
<p class="MsoNormal">On
2020-12-01 10:35 a.m., Nicolas
Cadieux wrote:</p>
</div>
<blockquote>
<p class="MsoNormal">Hi,
</p>
<div>
<p class="MsoNormal">Perhaps
this can help: <a
href="https://gdal.orgdrivers/raster/gpkg.html"
target="_blank"
moz-do-not-send="true">https://gdal.orgdrivers/raster/gpkg.html</a></p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p>“Various kind of input
datasets can be converted to
GeoPackage raster :</p>
<p>· Single band grey
level</p>
<p>· Single band with
R,G,B or R,G,B,A color table</p>
<p>· Two bands: first
band with grey level, second
band with alpha channel</p>
<p>· Three bands: Red,
Green, Blue</p>
<p>· Four band: Red,
Green, Blue, Alpha</p>
<p>GeoPackage rasters only
support Byte data type.”</p>
<p>My guess is that if the
original raster does not
correspond to one of the
categories above, it will be
converted to the closest
format. </p>
</div>
<div>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal">Nicolas
Cadieux
</p>
<div>
<p class="MsoNormal"><a
href="https://gitlab.com/njacadieux"
target="_blank"
moz-do-not-send="true">https://gitlab.com/njacadieux</a></p>
</div>
</div>
<div>
<p class="MsoNormal"> </p>
<blockquote>
<p class="MsoNormal">Le 1
déc. 2020 à 09:58,
Alberto Vavassori
<a
href="mailto:alberto.vavassori@polimi.it"
target="_blank"
moz-do-not-send="true"><alberto.vavassori@polimi.it></a>
a écrit :</p>
</blockquote>
</div>
<blockquote>
<div>
<p class="MsoNormal">
</p>
<p class="MsoNormal"><span
lang="EN-US">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.</span></p>
<p class="MsoNormal"><span
lang="EN-US">Has
anybody faced this
problem? May anybody
suggest a way to work
this problem out?</span></p>
<p class="MsoNormal"><span
lang="EN-US">Thank
you.</span></p>
<p class="MsoNormal"><span
lang="EN-US">Alberto</span></p>
<p class="MsoNormal">_______________________________________________<br>
Qgis-user mailing list<br>
<a
href="mailto:Qgis-user@lists.osgeo.org"
target="_blank"
moz-do-not-send="true">Qgis-user@lists.osgeo.org</a><br>
List info: <a
href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
target="_blank"
moz-do-not-send="true">
https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a
href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
target="_blank"
moz-do-not-send="true">
https://lists.osgeo.org/mailman/listinfo/qgis-user</a></p>
</div>
</blockquote>
</div>
</blockquote>
<pre>-- </pre>
<pre>Nicolas Cadieux</pre>
<pre><a href="https://gitlab.com/njacadieux" target="_blank" moz-do-not-send="true">https://gitlab.com/njacadieux</a></pre>
</div>
</blockquote>
<pre>-- </pre>
<pre>Nicolas Cadieux</pre>
<pre><a href="https://gitlab.com/njacadieux" target="_blank" moz-do-not-send="true">https://gitlab.com/njacadieux</a></pre>
</div>
<p class="MsoNormal">_______________________________________________<br>
Qgis-user mailing list<br>
<a
href="mailto:Qgis-user@lists.osgeo.org"
target="_blank"
moz-do-not-send="true">Qgis-user@lists.osgeo.org</a><br>
List info: <a
href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
target="_blank"
moz-do-not-send="true">
https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a
href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
target="_blank"
moz-do-not-send="true">
https://lists.osgeo.org/mailman/listinfo/qgis-user</a></p>
</blockquote>
</div>
</blockquote>
<pre>-- </pre>
<pre>Nicolas Cadieux</pre>
<pre><a href="https://gitlab.com/njacadieux" moz-do-not-send="true">https://gitlab.com/njacadieux</a></pre>
<p class="MsoNormal"><br>
<br>
</p>
<pre>_______________________________________________</pre>
<pre>Qgis-user mailing list</pre>
<pre><a href="mailto:Qgis-user@lists.osgeo.org" moz-do-not-send="true">Qgis-user@lists.osgeo.org</a></pre>
<pre>List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
<pre>Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
</blockquote>
<pre>-- </pre>
<pre>Kirk Schmidt, MScF, BScF, RPF</pre>
<pre>General Manager</pre>
<pre>Nortek Resource Solutions Inc.</pre>
<pre>RR # 1</pre>
<pre>Thorburn, NS</pre>
<pre>B0K 1W0</pre>
<pre>Tel (902) 922.3607</pre>
<pre>Email: <a href="mailto:kirk@nortekresources.com" moz-do-not-send="true">kirk@nortekresources.com</a></pre>
<pre>Web: <a href="http://www.nortekresources.com" moz-do-not-send="true">www.nortekresources.com</a></pre>
<p class="MsoNormal"><br>
<br>
</p>
<pre>_______________________________________________</pre>
<pre>Qgis-user mailing list</pre>
<pre><a href="mailto:Qgis-user@lists.osgeo.org" moz-do-not-send="true">Qgis-user@lists.osgeo.org</a></pre>
<pre>List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
<pre>Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
</blockquote>
<pre>-- </pre>
<pre>Nicolas Cadieux</pre>
<pre><a href="https://gitlab.com/njacadieux" moz-do-not-send="true">https://gitlab.com/njacadieux</a></pre>
<p class="MsoNormal"><br>
<br>
</p>
<pre>_______________________________________________</pre>
<pre>Qgis-user mailing list</pre>
<pre><a href="mailto:Qgis-user@lists.osgeo.org" moz-do-not-send="true">Qgis-user@lists.osgeo.org</a></pre>
<pre>List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
<pre>Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
</blockquote>
<pre>-- </pre>
<pre>Kirk Schmidt, MScF, BScF, RPF</pre>
<pre>General Manager</pre>
<pre>Nortek Resource Solutions Inc.</pre>
<pre>RR # 1</pre>
<pre>Thorburn, NS</pre>
<pre>B0K 1W0</pre>
<pre>Tel (902) 922.3607</pre>
<pre>Email: <a href="mailto:kirk@nortekresources.com" moz-do-not-send="true">kirk@nortekresources.com</a></pre>
<pre>Web: <a href="http://www.nortekresources.com" moz-do-not-send="true">www.nortekresources.com</a></pre>
<p class="MsoNormal"><br>
<br>
</p>
<pre>_______________________________________________</pre>
<pre>Qgis-user mailing list</pre>
<pre><a href="mailto:Qgis-user@lists.osgeo.org" moz-do-not-send="true">Qgis-user@lists.osgeo.org</a></pre>
<pre>List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
<pre>Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
</blockquote>
<pre>-- </pre>
<pre>Nicolas Cadieux</pre>
<pre><a href="https://gitlab.com/njacadieux" moz-do-not-send="true">https://gitlab.com/njacadieux</a></pre>
</blockquote>
<pre>-- </pre>
<pre>Kirk Schmidt, MScF, BScF, RPF</pre>
<pre>General Manager</pre>
<pre>Nortek Resource Solutions Inc.</pre>
<pre>RR # 1</pre>
<pre>Thorburn, NS</pre>
<pre>B0K 1W0</pre>
<pre>Tel (902) 922.3607</pre>
<pre>Email: <a href="mailto:kirk@nortekresources.com" moz-do-not-send="true">kirk@nortekresources.com</a></pre>
<pre>Web: <a href="http://www.nortekresources.com" moz-do-not-send="true">www.nortekresources.com</a></pre>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
<pre class="moz-signature" cols="72">--
Kirk Schmidt, MScF, BScF, RPF
General Manager
Nortek Resource Solutions Inc.
RR # 1
Thorburn, NS
B0K 1W0
Tel (902) 922.3607
Email: <a class="moz-txt-link-abbreviated" href="mailto:kirk@nortekresources.com">kirk@nortekresources.com</a>
Web: <a class="moz-txt-link-abbreviated" href="http://www.nortekresources.com">www.nortekresources.com</a></pre>
</body>
</html>