I have thousands of GeoTIFF source files that cover whole country in 6 different layers. I have created VRT file for each layer. I loaded everything in QGIS, assigning correct colors to bands in each VRT. I exported from QGIS a VRT of it all. When running the combined VRT through gdal2tiles, the resulting tiles are all either completely blue, or part lightblue. I suspect this corresponds to two different original sources of layers.

Is there a way to preserve the color palettes as defined in QGIS? The challenge is, that each layer is composed of hundreds of monochrome files, and it seems the color assignment wasn't saved?


I'm not sure if QGIS saves the band assignments in VRTs.

If you open the final VRT in a text editor, are the band assignments right? If your source band 4 is RED and should be the destination band 1, you should see:

<VRTRasterBand dataType="..." band="1">
    <ColorInterp> Red </ColorInterp>

near the top of the file, and then underneath you should see lines like:

    <SourceFilename relativeToVRT="0">...</SourceFilename>
    <SourceBand> 4 </SourceBand>

If you don't, then you should assign them when you build the layer VRT:

gdalbuildvrt -b 4 -b 2 -b 1 layer1.vrt layer1/*.tif

using the -b switch. The above example maps input bands [4,2,1] to output [1,2,3] which are [R,G,B].

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.