2

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?

1
  • It would help if you edited your question and provided some details about your geotiff, either the output of gdalinfo yourgeotiff.tif or copy the contents of layer properties - information tab in QGIS and paste as text (formatted as code) into your question.
    – user2856
    Jul 26 '20 at 3:51
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.