[gdal-dev] How to attach color tables to Tifs

Even Rouault even.rouault at mines-paris.org
Mon Oct 14 02:14:16 PDT 2013


Selon Moses.Gone at t-systems.com:

> Hallo List,
> In my tiling application am generating tiles with Gtiff as an output format.
> One of my inputs is of AIG format, however these inputs types comes with
> specific color tables, see sample below:
>
>    0 255 255 255  # No-Data
>    1   0   0 210  # Gewässer
>    5   0   0 200  # Klärschlammbecken >> Wasser
>   16 102 102 125  # Versiegelte Fläche
>   20 102 102 125  # Brücken
>   32 191 191   0  # Sand, Abbau
>   33 191 191   0  # >> Sand, Abbau
>   48 125  51   0  # Fels
>   64 255 255   0  # Heide >> LaWi
>   68 255 255   0  # Moor >> LaWi
>   72 255 255   0  # Feuchtgebiete  >> LaWi
>   80 255 255   0  # Landwirtschaft genutzte Fläche
>   96 224 255   0  # Mischung Wald/Feld, Park
>  100 255 180   0  # Weinbau
>  101   0   0   0  # Gewächshaus
>  102 140 255   0  # Obstbau
>  112   0 125   0  # Wald, undifferenziert
>  116  35 214   0  # Laubwald
>  120   0 214  65  # Nadelwald
>  176 255 100   0  # Vorstadt
>  208 255  50   0  # Stadt, locker bebaut
>  212 153 0  153   # Stadt, große Einzelgebäude
>  224 255   0   0  # Stadt, dicht bebaut
>  240 153  0    0  # Stadt, extrem dicht bebaut, Innenstädte
>  241 153  0    0  # Stadt, extrem dicht bebaut, Industrieflächen >> 240
>
>
> Now, what is the best way to attach this color table to my output tifs? BTW,
> my tifs are 8-bit(1-band) I read somewhere that I have to first convert my
> tif to vrt, then manually update the <ColorTable> section with entries for
> each color, like this:
>
>   <ColorTable>
>       <Entry c1="238" c2="238" c3="238" />
>       <Entry c1="237" c2="237" c3="237" />
>       <Entry c1="236" c2="236" c3="236" />
>       <Entry c1="229" c2="229" c3="229" />
>     </ColorTable>
>
> Is this the right approach? Besides, I would like to automate the whole
> workflow. Is there a script that I can use to automate this workflow?

That's an approach, but uou likely want to use the following script :

http://svn.osgeo.org/gdal/trunk/gdal/swig/python/samples/attachpct.py

Even


More information about the gdal-dev mailing list