[gdal-dev] Saving style/color table inside tiff

Even Rouault even.rouault at spatialys.com
Mon Oct 30 13:53:21 PDT 2017


On lundi 30 octobre 2017 15:36:43 CET Idan Miara wrote:
> Hi,
> 
> I would like to ask a few questions regarding color table/style inside
> Tiffs (or any other standard raster format for that matter):
> 
> 1. Single Band Byte Raster without scale/offset - I could a Byte band Tiff
> with color table with gdal and load it successfully in QGIS, but if I try
> to save a copy of that raster from within QGIS then it doesn't save the
> color table, I get a grayscale raster as output.
Probably QGIS limitation
> 
> 2. Single Band non-Byte Raster - I could not save a float/int16 raster with
> gdal, gdal just ignores the color table commands for non-byte raster. Is
> there an option to save a color representation for non-byte raster inside
> the raster itself? 
GDAL supports writing color table in TIFF for Byte and UInt16 (not Int16). This is a limitation 
of the TIFF format. And actually this is more a fundamental limitation. Color table (in the 
strict sense) wouldn't make sense for other data types. For float, you need more to define 
ranges, with interpolation when a value is in the middle of a range. Typically what the 
gdaldem color-relief utility does with .cpt files.

> if not, what is a good practice for that ? is there a
> standard cross application raster-style format? I could only see that QGIS
> supports QML, which I guess is QGIS specific.
> 
> 3. Single Band Byte raster with scale/offset - if I set a scale/offset to
> my Byte raster then QGIS automatically converts it to Float32 raster upon
> loading, I guess it's a QGIS limitation. I could not find a way to
> scale/offset the color table itself, thus the raster cannot be colored
> correctly with scale/offset. i.e. for scale=2, the raster values are 0-511,
> but the color palette is only 0-255 so there is no way to color correctly
> the values>255.

Hum, I believe that the semantics of scale/offset + color table is not well defined in GDAL. 

> 
> Idan.


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171030/4807c258/attachment.html>


More information about the gdal-dev mailing list