ubarsc / tuiview

TuiView is a lightweight raster GIS with powerful raster attribute table manipulation abilities
http://tuiview.org/
GNU General Public License v2.0
26 stars 13 forks source link

Palette images not recognised #80

Open howff opened 3 months ago

howff commented 3 months ago

I have a TIFF image with a palette but when I load it into tuiview it displays as greyscale, and says "no color table present"

Driver: GTiff/GeoTIFF
Files: no.tif
Size is 20000, 20000
Image Structure Metadata:
  COMPRESSION=LZW
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,20000.0)
Upper Right (20000.0,    0.0)
Lower Right (20000.0,20000.0)
Center      (10000.0,10000.0)
Band 1 Block=20000x48 Type=Byte, ColorInterp=Palette
  Color Table (RGB with 256 entries)
    0: 0,0,0,255
    1: 11,13,14,255
etc
gillins commented 3 months ago

TuiView currently only recognises colour tables written into the Raster Attribute Table. This is partly because tuiview was conceived as a tool for working with RATs, but also because the (older) colour table API is very slow to use from Python (have to read each row individually, not all at once like RATs).

So see if you can write the colour table to the RAT. You will also have to ensure the file is set to thematic (LAYER_TYPE=thematic in the band metadata or controls.setThematic(True) in RIOS).

If you feel strongly about this, I'm open to a PR to read the ColorTable if the RAT is missing - would be good if it didn't change the code around too much though.