2

I have a three-band raster:

enter image description here

I would like to convert this to a single-band raster using QGIS, but retain the colours from the three-band version. I can use the Raster Calculator to create a single-band raster with ("File@1" + "File@2" + "File@3") / 3 , but this gives a greyscale version:

enter image description here

How can I transfer the original colours from the three-band raster? I'm sure there should be a way to do this, but I don't know what I should be searching for. Perhaps this is similar to this question using R, about extracting the colour table from a raster? I thought it might be something like Toolbox > GRASS > Raster > r.colors but the output of that tool doesn't seem relevant?


Edit

In response to a comment below, here is the sort of output I hope for. A single band raster, with unique colours for each of the 256 colours:

enter image description here

3
  • You could export/convert to jpeg.
    – Erik
    Commented Jun 30, 2021 at 8:23
  • @Erik I could use GDAL translate to make a jpeg, but the output file still has three bands? Also I prefer to keep it as a raster because I have to do more analysis on it afterwards.
    – EcologyTom
    Commented Jun 30, 2021 at 8:37
  • 2
    @Babel by using the Paletted/Unique values option in the layer symbology. The key is using colour values that "make sense", i.e not just random colours. The difficulty is finding out what those colour values should be. I've added an example where this is used to my question, but I can't just copy the layer style as the raster values are not the same.
    – EcologyTom
    Commented Jun 30, 2021 at 8:55

0

Your Answer

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

Browse other questions tagged or ask your own question.