[gdal-dev] More information to understand ColorTables in GeoTiffs
Robert Nix
robert at urban4m.com
Fri Mar 8 13:35:44 PST 2013
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130308/9c691b40/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1437 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130308/9c691b40/attachment.bin>
More information about the gdal-dev
mailing list