[gdal-dev] Is it possible to have an external Color Table definition for GeoTIFF rasters?

Denis Rykov rykovd at gmail.com
Wed Nov 24 02:51:50 PST 2021


For example it works in case of ASCII rasters:

$ cat test.ascii.aux.xml <PAMDataset> <PAMRasterBand band="1"> <ColorInterp>
Palette</ColorInterp> <ColorTable> <Entry c1="0" c2="0" c3="0" c4="0" /> <
Entry c1="1" c2="2" c3="3" c4="4" /> <Entry c1="2" c2="4" c3="6" c4="8" /> <
Entry c1="3" c2="6" c3="9" c4="12" /> <Entry c1="4" c2="8" c3="12" c4="16"
/> </ColorTable> <Metadata> <MDI key="STATISTICS_MAXIMUM">4</MDI> <MDI key=
"STATISTICS_MEAN">1.75</MDI> <MDI key="STATISTICS_MINIMUM">0</MDI> <MDI key=
"STATISTICS_STDDEV">1.4790199457749</MDI> </Metadata> </PAMRasterBand> </
PAMDataset>

$ gdalinfo test.ascii Driver: AAIGrid/Arc/Info ASCII Grid Files: test.ascii
test.ascii.aux.xml Size is 5, 1 Origin =
(0.000000000000000,0.000000000000000) Pixel Size =
(1.000000000000000,-1.000000000000000) Corner Coordinates: Upper Left (
0.0000000, 0.0000000) Lower Left ( 0.0000000, -1.0000000) Upper Right (
5.0000000, 0.0000000) Lower Right ( 5.0000000, -1.0000000) Center (
2.5000000, -0.5000000) Band 1 Block=5x1 Type=Int32, ColorInterp=Palette
Min=0.000 Max=4.000 Minimum=0.000, Maximum=4.000, Mean=1.750, StdDev=1.479
NoData Value=3 Metadata: STATISTICS_MAXIMUM=4 STATISTICS_MEAN=1.75
STATISTICS_MINIMUM=0 STATISTICS_STDDEV=1.4790199457749 Color Table (RGB
with 5 entries) 0: 0,0,0,0 1: 1,2,3,4 2: 2,4,6,8 3: 3,6,9,12 4: 4,8,12,16

But the same approach (having a color table in external .aux.xml PAM file)
doesn't work for GeoTIFF rasters. According to the output of gdal_translate
we can see that GDAL doesn't take into account the color table defined in
the external file.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211124/8839a053/attachment.html>


More information about the gdal-dev mailing list