2

Using QGIS's Merge and Rearrange raster tools, I have created a 5-band raster based on:

  • A RGB raster with an alpha band,
  • A single-band NIR raster.

The original RGB raster's bands are all automatically detected and interpreted by QGIS (screenshot). I want to reproduce this for my new raster.

Symbology menu for the original RGB raster. Each band is labaled with a color interpretation.

Using the Raster information... tool (as suggested here), I can see a ColorInterp parameter in the generated html file. However, I cannot find a matching parameter in the xml file.

Side by side view of the html raster information (left) and xml file (right).

Here is a transcription of the metadata:

<PAMDataset>
  <PAMRasterBand band="1">
    <UnitType>metre</UnitType>
    <Metadata>
      <MDI key="STATISTICS_MAXIMUM">255</MDI>
      <MDI key="STATISTICS_MEAN">137.68055874329</MDI>
      <MDI key="STATISTICS_MINIMUM">5</MDI>
      <MDI key="STATISTICS_STDDEV">78.204976720939</MDI>
      <MDI key="STATISTICS_VALID_PERCENT">100</MDI>
    </Metadata>
  </PAMRasterBand>
  <PAMRasterBand band="2">
    <UnitType>metre</UnitType>
    <Metadata>
      <MDI key="STATISTICS_MAXIMUM">255</MDI>
      <MDI key="STATISTICS_MEAN">146.04449533328</MDI>
      <MDI key="STATISTICS_MINIMUM">16</MDI>
      <MDI key="STATISTICS_STDDEV">72.316293490795</MDI>
      <MDI key="STATISTICS_VALID_PERCENT">100</MDI>
    </Metadata>
  </PAMRasterBand>
  <PAMRasterBand band="3">
    <UnitType>metre</UnitType>
    <Metadata>
      <MDI key="STATISTICS_MAXIMUM">255</MDI>
      <MDI key="STATISTICS_MEAN">110.86670480457</MDI>
      <MDI key="STATISTICS_MINIMUM">0</MDI>
      <MDI key="STATISTICS_STDDEV">93.577575298367</MDI>
      <MDI key="STATISTICS_VALID_PERCENT">100</MDI>
    </Metadata>
  </PAMRasterBand>
  <PAMRasterBand band="4">
    <UnitType>metre</UnitType>
    <Metadata>
      <MDI key="STATISTICS_MAXIMUM">255</MDI>
      <MDI key="STATISTICS_MEAN">181.04600155079</MDI>
      <MDI key="STATISTICS_MINIMUM">0</MDI>
      <MDI key="STATISTICS_STDDEV">115.71117369521</MDI>
      <MDI key="STATISTICS_VALID_PERCENT">100</MDI>
    </Metadata>
  </PAMRasterBand>
</PAMDataset>

I am using QGIS 3.10 to read and display the raster.

How can I coerce QGIS to default to the proper color interpretation?

2 Answers 2

1

Old mate in How do you label bands in a GDAL VRT so that their label is recognised in QGIS encountered a similar problem

From his problem I found that manually inserting <ColorInterp> into a .vrt did the trick, I wonder if it works the same for your .xml

Insert colour interp

1
  • I'm seeing your reply a year later. Apologies for the delayed response. It didn't quite do the trick. QGIS still puts the first band (Blue) first (rendered in red) by default. But it did add "(Blue)" behind its name.
    – ChloeG
    Commented Sep 13 at 9:19
0

I found a workaround, creating a .qml style file as described in this tutorial. This is good enough for me to move forward with my project.

However, if anyone could still shed light on what is happening with the original file (where/how the ColorInterpret information is stored), I would be happy to read about it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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