[gdal-dev] Modify an image color table?

Frank Warmerdam warmerdam at pobox.com
Fri Jun 25 08:12:57 EDT 2010


Marco Stelluti wrote:
> Hi,
> I'm a new gdal user and I've a little problem.
> 
> I have to modify the color to an ASCII raster.
> 
> 1_ I converted the raster using gdalbuildvrt;
> 2_ I modified the file *.vrt adding:
>     <ColorInterp>Palette</ColorInterp>
>  <ColorTable>
> <Entry c1="255" c2="255" c3="255" c4="255"/>
> <Entry c1="0" c2="0" c3="150" c4="255"/>
> <Entry c1="0" c2="0" c3="150" c4="255"/>
> .......
>  </ColorTable>
> 3_ I know: "The entries are ordered and will be assumed to start from 
> color table entry 0"
> 4_ But I have some negative value on the ASCII raster, the range is from 
> -31 to 65.
> 5_ How I can resolve this problem?

Marco,

Generally speaking GDAL color maps do not have an obvious application
to negative or non-integer data.  You could use the "raster attribute table"
mechanism to represent color assignments to negative values, but since so
few applications make use of this data object it is nearly useless to do so.

What application do you want the color table to work in?  How you handle
the situation will depend on the output application.   If preserving the
original pixel values isn't important you may want to reprocess/rescale your
raster.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list