Hi,

I'm trying to add a color table to a 1-band UInt16 GeoTiff with Python as 
follows:

import numpy as np
import gdal

driver = gdal.GetDriverByName('GTiff')
dst_ds = driver.Create('testcolor.tif', 100, 100, 1, gdal.GDT_UInt16)

band = dst_ds.GetRasterBand(1)
band.SetRasterColorInterpretation(gdal.GCI_PaletteIndex)

c = gdal.ColorTable(gdal.GCI_PaletteIndex)
c.SetColorEntry(1,(255,127,0,63))
band.SetColorTable(c)

a = np.random.randint(1,10,size=(100,100))
band.WriteArray(a)

dst_ds = None

The problem is that when i run gdalinfo on the testcolor.tif, it lists 65535 
color table entries:

Driver: GTiff/GeoTIFF
Files: testcolor.tif
       testcolor.tif.aux.xml
Size is 100, 100
Coordinate System is `'
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  100.0)
Upper Right (  100.0,    0.0)
Lower Right (  100.0,  100.0)
Center      (   50.0,   50.0)
Band 1 Block=100x40 Type=UInt16, ColorInterp=Palette
  Color Table (RGB with 65536 entries)
    0: 1,0,0,255
    1: 1,0,0,255
    2: 0,0,0,255
    3: 0,0,0,255
...
  65533: 0,0,0,255
  65534: 0,0,0,255
  65535: 0,0,0,255

What's going on … besides the fact that maybe i'm not understanding 
color-tables? If it's clear i don't understand, is there a good resource for 
understanding color-tables? Or must I go learn the source code (which i really 
don't have to do)?

Thanks
--nix

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to