[gdal-dev] translating palettes in geotiff
Even Rouault
even.rouault at mines-paris.org
Tue Apr 23 13:38:11 PDT 2013
Le mardi 23 avril 2013 22:36:10, David Strip a écrit :
> On 4/23/2013 2:11 PM, Even Rouault wrote:
> > Le mardi 23 avril 2013 21:52:39, David Strip a écrit :
> >> I have a paletted geotiff that I want to modify by mapping palette
> >> entries to a new palette.
> >> Thus, I have an input palette, an output palette, and a geotiff. I have
> >> a mapping (many to 1, if it matters) from the input palette to the
> >> output palette. Each pixel in the output geotiff will have a value
> >> equivalent to mapping the input geotiff's pixel value through the map.
> >>
> >> I've looked over the utilities and none seems to have this capability.
> >> It would be pretty easy, I think to write code using gdal to do this,
> >> but if one of the utilities will handle this case, that's even better.
> >
> > One possibility would be to use a VRT file where you specify a <LUT>
> > element to map the indices from the input palette to the indices of the
> > output palette. See http://www.gdal.org/gdal_vrttut.html for the syntax.
>
> I was wondering whether a vrt would do the trick, but I'm not that
> familiar. If I'm reading this right, the path is something like
> translate from geotiff to vrt
> add the LUT
> translate from vrt back to geotiff.
>
> If I'm going to be doing this a lot, with input files of the same size,
> all I need to do is create the .vrt as above, then edit the
> SourceFileName tag to point to the appropriate input file.
Yes, actually you need to mix my above solution with Jukka's one since, in
addition to the LUT that will do the mapping of pixel values, you also need to
add the new color table in the VRT.
>
> Is that right?
> Many thanks
More information about the gdal-dev
mailing list