From Even's advice, I was able to piece together this workflow.
Given an input geotiff  image.gtif
gdaltranslate -of image.gtif image.vrt

Then open image.vrt in a text editor and look for the color table by searching for the tag <ColorTable> (actually you probably don't need to search, it's near the top) Replace the contents of the color palette with the palette entries you want on output.

Then below the color table look for <SimpleSource> and replace it with <ComplexSource>
Look for </SimpleSource> and replace with <ComplexSource>
Add a new line above </ComplexSource> that looks like
<LUT>input_color_index:output_color_index, input_color_index:output_color_index, ... </LUT> for example if you want to map input palette entry 1 to output entry 10, input 3, to output 5, ...
<LUT>1:10, 3:5, ...<LUT>
You will need to map EVERY input color that occurs in your image to an output color or else gdal_translate will interpolate a color for you, and you don't want that.
Now that you've edited the file run
gdal_translate -of gtiff image.vrt mapped_image.gtif

And you're done.

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to