1

I have a folder containing 79 tiled Geotiff rasters making up a basemap of the UK. My goal is to efficiently store these in a Geopackage which already contains some vector data also used for base mapping.

  • The tiled images are all single band paletted images, and are 8 bit unsigned integers.

Here is an example segment: enter image description here

So far I have tried merging all tiles into a mosaic using the merge tool in QGIS 3.0.3. I enabled the "Grab psuedocolor table from first layer" option and then tried selecting an appropriate data type. They did not have 8 bit unsigned integer so the closest I got was 16 bit unsigned integer (I am not sure if this messes things up).

I then used the translate tool to save it into the geopackage but the results come out as below:
enter image description here

Is it possible to nicely stored these into a Geopackage or is it not possible yet?

  • I'm pretty sure those tiffs don't share a color palette so "Grab psuedocolor table from first layer" is probably not what you want. – Ian Turton Jun 20 '18 at 8:46
2

I thought that maybe merge without selecting the "Grab psuedocolor table from first layer" would work, but I just end up with a black and white image.

I then thought that creating a VRT would work, but that fails horribly with just primary colour squares for each tile, until you remember to uncheck layer stack. But when you save it as a GeoPackage it becomes black and white.

The only solution I can come up with is to use PCT to RGB on each tile before combining them (I would probably go with a VRT rather than merge) and then saving as a GeoPackage layer.

I used a zsh loop to do this:

for i in tq/TQ??.tif
do
  pct2rgb.py $i ${i:r}_new.tif -of GTiff -b 1
done
  • Thanks for testing this - your solution worked for me, and thanks for the code – AWGIS Jun 20 '18 at 10:59
  • Does a VRT need to be stored with the original images? So if I save the VRT into a Geopackage how does this work? – AWGIS Jun 20 '18 at 11:02
  • 1
    I think that QGis will use the VRT to look up each tile, but writes the actual pixels into the GeoPackage so it becomes independent. – Ian Turton Jun 20 '18 at 11:03
  • I get this error when trying to build a VRT with the RGB tilesTraceback (most recent call last): File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\algs\qgis\Datasources2Vrt.py", line 102, in processAlgorithm feedback=feedback) File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\algs\qgis\Datasources2Vrt.py", line 133, in mergeDataSources2Vrt self.tr('Invalid datasource: {}'.format(inFile))) _core.QgsProcessingException: Invalid datasource: C:/Users/AWGIS/Desktop/UK & Ireland Panorama 200 v2018/PCT to RGB/PCBHP.tif Execution failed after 6.92 seconds – AWGIS Jun 20 '18 at 11:33
  • 2
    I usually try to avoid spaces in my paths as this can often cause issues – Ian Turton Jun 20 '18 at 12:06

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.