[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

jratike80 jukka.rahkonen at maanmittauslaitos.fi
Wed Dec 2 13:16:11 PST 2020


It might be good to read also about the open options in
https://gdal.org/drivers/raster/gpkg.html

"BAND_COUNT=1/2/3/4: Number of bands of the dataset exposed after opening.
Some conversions will be done when possible and implemented, but this might
fail in some cases, depending on the BAND_COUNT value and the number of
bands of the tile. Defaults to 4 (which is the always safe value)."

-Jukka Rahkonen-


Even Rouault-2 wrote
> On mercredi 2 décembre 2020 15:16:44 CET Nicolas Cadieux wrote:
>> 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
>> 
> 
> The answer is there:
> https://gdal.org/drivers/raster/gpkg.html#tile-formats
> 
> For Byte input (that isn't recognized as to be used by the tiled gridded 
> coverage data), the default tile format will use JPEG lossy compression
> for 
> tiles with a fully opaque channel.
> 
> -co TILE_FORMAT=PNG will use lossless compression
> 
> GeoPackage raster aim was initially for visualisation purposes, hence this 
> default. The more analytic side was a later addition to the format, and 
> actually an extension
> 
> Even
> 
> -- 
> Spatialys - Geospatial professional services
> http://www.spatialys.com
> _______________________________________________
> gdal-dev mailing list

> gdal-dev at .osgeo

> https://lists.osgeo.org/mailman/listinfo/gdal-dev





--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html


More information about the gdal-dev mailing list