<div dir="ltr"><div>For example it works in case of ASCII rasters:<br></div><div><br><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">$ cat test.ascii.aux.xml 
</span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">PAMDataset</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
   </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">PAMRasterBand</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">band</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"1"</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
      </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">ColorInterp</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">Palette</span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"></<span class="gmail-hljs-name">ColorInterp</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
      </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">ColorTable</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
         </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">Entry</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c1</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"0"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c2</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"0"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c3</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"0"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c4</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"0"</span> /></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
         </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">Entry</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c1</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"1"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c2</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"2"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c3</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"3"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c4</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"4"</span> /></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
         </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">Entry</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c1</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"2"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c2</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"4"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c3</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"6"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c4</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"8"</span> /></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
         </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">Entry</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c1</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"3"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c2</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"6"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c3</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"9"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c4</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"12"</span> /></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
         </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">Entry</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c1</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"4"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c2</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"8"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c3</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"12"</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">c4</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"16"</span> /></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
      </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"></<span class="gmail-hljs-name">ColorTable</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
      </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">Metadata</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
         </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">MDI</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">key</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"STATISTICS_MAXIMUM"</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">4</span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"></<span class="gmail-hljs-name">MDI</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
         </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">MDI</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">key</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"STATISTICS_MEAN"</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">1.75</span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"></<span class="gmail-hljs-name">MDI</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
         </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">MDI</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">key</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"STATISTICS_MINIMUM"</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">0</span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"></<span class="gmail-hljs-name">MDI</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
         </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><<span class="gmail-hljs-name">MDI</span> <span class="gmail-hljs-attr" style="color:rgb(255,0,0)">key</span>=<span class="gmail-hljs-string" style="color:rgb(163,21,21)">"STATISTICS_STDDEV"</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">1.4790199457749</span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"></<span class="gmail-hljs-name">MDI</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
      </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"></<span class="gmail-hljs-name">Metadata</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
   </span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"></<span class="gmail-hljs-name">PAMRasterBand</span>></span><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">
</span><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"></<span class="gmail-hljs-name">PAMDataset</span>></span><br></div><div><span class="gmail-hljs-tag" style="color:rgb(0,0,255);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><br></span></div><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap">$ 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</span><br><div><span style="color:rgb(0,0,0);font-family:Monaco,"Andale Mono","Courier New",monospace;font-size:12px;white-space:pre-wrap"><br></span></div>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. </div>