TransWikia.com

Save 1-band-raster to geopackage results in 4-band-raster

Geographic Information Systems Asked on December 29, 2021

I have a 1-band-raster (geotiff) and want to export it to a geopackage in QGIS 3.14. When I do that (right-click –> export –> save as), it results in a 4-band-raster. How can I prevent that?

One Answer

Probably the tiles are stored with 1 band but GDAL just reports that there are 4 bands. That is documented in 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.

I had a test by converting 1-band GeoTIFF into GeoPackage and gdalinfo indeed behaves as documented.

gdalinfo 1_band_gdal.gpkg
...
Band 1 Block=256x256 Type=Byte, ColorInterp=Red
  Mask Flags: PER_DATASET ALPHA
Band 2 Block=256x256 Type=Byte, ColorInterp=Green
  Mask Flags: PER_DATASET ALPHA
Band 3 Block=256x256 Type=Byte, ColorInterp=Blue
  Mask Flags: PER_DATASET ALPHA
Band 4 Block=256x256 Type=Byte, ColorInterp=Alpha

gdalinfo 1_band_gdal.gpkg -oo band_count=1
…
Band 1 Block=256x256 Type=Byte, ColorInterp=Gray

Answered by user30184 on December 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP