I have a tiff raster with values from 0 to 255 (one band) and 7 colors. I would like to change colors of my tiff.

I tried with QGIS but I can't save it with new colors.

enter image description here from this

enter image description here to that

Somebody have an idea ?

1 Answer 1


Convert your image into GDAL virtual raster http://www.gdal.org/gdal_vrttut.html with gdal_translate.

gdal_translate -of vrt test.tif test.vrt

GDAL VRT raster is a small XML file than contains instructions about how to handle the source data and it contains also the palette as plain text.

 <VRTRasterBand dataType="Byte" band="1">
      <Entry c1="120" c2="120" c3="120" c4="255" />
      <Entry c1="72" c2="72" c3="72" c4="255" />
      <Entry c1="176" c2="176" c3="184" c4="255" />
      <Entry c1="160" c2="136" c3="200" c4="255" />
      <Entry c1="120" c2="184" c3="224" c4="255" />
      <Entry c1="152" c2="152" c3="152" c4="255" />
      <Entry c1="152" c2="200" c3="248" c4="255" />
      <Entry c1="208" c2="240" c3="224" c4="255" />
      <Entry c1="176" c2="224" c3="248" c4="255" />
      <Entry c1="240" c2="200" c3="216" c4="255" />
      <Entry c1="224" c2="224" c3="224" c4="255" />
      <Entry c1="0" c2="0" c3="0" c4="255" />

Edit the RGBA values in the palette entries as you wish, save the VRT file and open that with QGIS. You should see your edited colors. What't the best is that you have still the original image left because you have not touched it at all so you even have the same physical image opened as several differently colored versions. But if you want to materialize the new version use gdal_translate once again:

gdal_translate -of GTiff test.vrt modified_palette.tif
  • Original tiff file is alone and my goal is to generate a new tiff with new colors but without side file.
    – Tim C.
    Commented Feb 27, 2018 at 10:36
  • 2
    @Tim then gdal_translate your vrt to a tiff.
    – user2856
    Commented Feb 27, 2018 at 10:42

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.