[Qgis-user] R: Importing a raster into a Geopackage
Kirk Schmidt
kirk at nortekresources.com
Wed Dec 2 07:00:15 PST 2020
Hi all:
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.
Kirk
On 12/1/2020 3:24 PM, Nicolas Cadieux wrote:
>
> Hi,
>
> I changed the link so you have access to more files.
>
> https://drive.google.com/drive/folders/1fMl9odowUFFRQFK61rTxgHeom_D8ymN6?usp=sharing
>
> Nicolas
>
> On 2020-12-01 1:58 p.m., Kirk Schmidt wrote:
>>
>> Hi Nicolas
>>
>> 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.
>>
>> Kirk
>>
>> On 12/1/2020 2:36 PM, Nicolas Cadieux wrote:
>>>
>>> Hi,
>>>
>>> Tried this:
>>>
>>> gdal_translate -of GPKG -b 1
>>> C:/Users/Nicolas/Desktop/Land_cover_Corine2018.tif
>>> C:/Users/Nicolas/Desktop/test.gpkg
>>>
>>> I read 4 band and still get data modifications.
>>>
>>> Nicolas
>>>
>>> On 2020-12-01 1:28 p.m., Kirk Schmidt wrote:
>>>>
>>>> Hi Nicolas:
>>>>
>>>> try the -b 1 parameter. I just tried this and wrote a single band
>>>> raster from a 3 channel tiff.
>>>>
>>>> Kirk
>>>>
>>>> On 12/1/2020 2:03 PM, Nicolas Cadieux wrote:
>>>>>
>>>>> I tried
>>>>>
>>>>> 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
>>>>>
>>>>> C:\>gdal_translate -of GPKG -co "TILE_FORMAT = TIFF"
>>>>> C:/Users/Nicolas/Desktop/Land_cover_Corine2018.tif
>>>>> C:/Users/Nicolas/Desktop/TEST.gpkg
>>>>>
>>>>> Same problem. I wonder if we need to change the reading
>>>>> options... https://gdal.org/drivers/raster/gpkg.html
>>>>>
>>>>>
>>>>> "Opening options
>>>>>
>>>>> 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."
>>>>>
>>>>> 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.
>>>>>
>>>>> Nicolas
>>>>>
>>>>>
>>>>> On 2020-12-01 12:17 p.m., Sebastian Gutwein wrote:
>>>>>> This looks like the same issue you are having.
>>>>>> github.com/qgis/QGIS/issues/38227
>>>>>> <http://github.com/qgis/QGIS/issues/38227>
>>>>>> According to the documentation linked in the issue you need to
>>>>>> set the band count to 1 otherwise it defaults to 4.
>>>>>> gdal.org/drivers/raster/gpkg.html
>>>>>> <http://gdal.org/drivers/raster/gpkg.html>
>>>>>> I have not tried this to see if it works.
>>>>>>
>>>>>> On Tue, Dec 1, 2020 at 11:52 AM Nicolas Cadieux
>>>>>> <njacadieux.gitlab at gmail.com
>>>>>> <mailto:njacadieux.gitlab at gmail.com>> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Looking at it now. I see what you see. I will try a few things.
>>>>>>
>>>>>> Nicolas
>>>>>>
>>>>>> On 2020-12-01 11:42 a.m., Alberto Vavassori wrote:
>>>>>>>
>>>>>>> Hi Nicolas,
>>>>>>>
>>>>>>> thank you for the answer. I send the raster that I am
>>>>>>> interested in.
>>>>>>>
>>>>>>> Alberto
>>>>>>>
>>>>>>> *Da:*Nicolas Cadieux <njacadieux.gitlab at gmail.com>
>>>>>>> <mailto:njacadieux.gitlab at gmail.com>
>>>>>>> *Inviato:* martedì 1 dicembre 2020 17:40
>>>>>>> *A:* Alberto Vavassori <alberto.vavassori at polimi.it>
>>>>>>> <mailto:alberto.vavassori at polimi.it>
>>>>>>> *Cc:* qgis-user at lists.osgeo.org
>>>>>>> <mailto:qgis-user at lists.osgeo.org>
>>>>>>> *Oggetto:* Re: [Qgis-user] Importing a raster into a Geopackage
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Send a sample data set if you can't figure it out.
>>>>>>>
>>>>>>> Nicolas
>>>>>>>
>>>>>>> On 2020-12-01 10:35 a.m., Nicolas Cadieux wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Perhaps this can help:
>>>>>>> https://gdal.orgdrivers/raster/gpkg.html
>>>>>>> <https://gdal.orgdrivers/raster/gpkg.html>
>>>>>>>
>>>>>>> “Various kind of input datasets can be converted to
>>>>>>> GeoPackage raster :
>>>>>>>
>>>>>>> ·Single band grey level
>>>>>>>
>>>>>>> ·Single band with R,G,B or R,G,B,A color table
>>>>>>>
>>>>>>> ·Two bands: first band with grey level, second band with
>>>>>>> alpha channel
>>>>>>>
>>>>>>> ·Three bands: Red, Green, Blue
>>>>>>>
>>>>>>> ·Four band: Red, Green, Blue, Alpha
>>>>>>>
>>>>>>> GeoPackage rasters only support Byte data type.”
>>>>>>>
>>>>>>> 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.
>>>>>>>
>>>>>>> Nicolas Cadieux
>>>>>>>
>>>>>>> https://gitlab.com/njacadieux
>>>>>>> <https://gitlab.com/njacadieux>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Le 1 déc. 2020 à 09:58, Alberto Vavassori
>>>>>>> <alberto.vavassori at polimi.it>
>>>>>>> <mailto:alberto.vavassori at polimi.it> a écrit :
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 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.
>>>>>>>
>>>>>>> Has anybody faced this problem? May anybody suggest
>>>>>>> a way to work this problem out?
>>>>>>>
>>>>>>> Thank you.
>>>>>>>
>>>>>>> Alberto
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Qgis-user mailing list
>>>>>>> Qgis-user at lists.osgeo.org
>>>>>>> <mailto:Qgis-user at lists.osgeo.org>
>>>>>>> List info:
>>>>>>> https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>>>> <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>>>>>>> Unsubscribe:
>>>>>>> https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>>>> <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>>>>>>>
>>>>>>> --
>>>>>>> Nicolas Cadieux
>>>>>>> https://gitlab.com/njacadieux <https://gitlab.com/njacadieux>
>>>>>>
>>>>>> --
>>>>>> Nicolas Cadieux
>>>>>> https://gitlab.com/njacadieux <https://gitlab.com/njacadieux>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Qgis-user mailing list
>>>>>> Qgis-user at lists.osgeo.org <mailto:Qgis-user at lists.osgeo.org>
>>>>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>>> <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>>>>>> Unsubscribe:
>>>>>> https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>>> <https://lists.osgeo.org/mailman/listinfo/qgis-user>
>>>>>>
>>>>> --
>>>>> Nicolas Cadieux
>>>>> https://gitlab.com/njacadieux
>>>>>
>>>>> _______________________________________________
>>>>> Qgis-user mailing list
>>>>> Qgis-user at lists.osgeo.org
>>>>> List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>>> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>> --
>>>> Kirk Schmidt, MScF, BScF, RPF
>>>> General Manager
>>>> Nortek Resource Solutions Inc.
>>>> RR # 1
>>>> Thorburn, NS
>>>> B0K 1W0
>>>> Tel (902) 922.3607
>>>> Email:kirk at nortekresources.com
>>>> Web:www.nortekresources.com
>>>>
>>>> _______________________________________________
>>>> Qgis-user mailing list
>>>> Qgis-user at lists.osgeo.org
>>>> List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
>>>> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> --
>>> Nicolas Cadieux
>>> https://gitlab.com/njacadieux
>>>
>>> _______________________________________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
>>> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user
>> --
>> Kirk Schmidt, MScF, BScF, RPF
>> General Manager
>> Nortek Resource Solutions Inc.
>> RR # 1
>> Thorburn, NS
>> B0K 1W0
>> Tel (902) 922.3607
>> Email:kirk at nortekresources.com
>> Web:www.nortekresources.com
>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user
> --
> Nicolas Cadieux
> https://gitlab.com/njacadieux
--
Kirk Schmidt, MScF, BScF, RPF
General Manager
Nortek Resource Solutions Inc.
RR # 1
Thorburn, NS
B0K 1W0
Tel (902) 922.3607
Email: kirk at nortekresources.com
Web: www.nortekresources.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20201202/98a94c3b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hpfgmdgdogpifobk.png
Type: image/png
Size: 7267 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20201202/98a94c3b/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jplddkbmmncmfdin.png
Type: image/png
Size: 6790 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20201202/98a94c3b/attachment-0003.png>
More information about the Qgis-user
mailing list