[gdal-dev] How to map Int32 or Float32 GTiff to color map?

Stephen Woodbridge woodbri at swoodbridge.com
Thu May 15 07:25:12 PDT 2014


Hi all,

I'm trying to create a VRT file for a GTiff that is Int32 or Float32 to 
add a ColorTable but I seem to be missing a key piece of information. 
How are the pixel values mapped to the color table entries? via the 
histogram?

My GTiff has noData=-32767 and good values the range from say -5 to 100. 
So do I create a color table that is based on the 256 buckets in the 
histogram?

So for example I get:

Band 1 Block=256x256 Type=Float32, ColorInterp=Gray
   Min=-32767.000 Max=33.980   Computed Min/Max=-54.985,34.320
   Minimum=-32767.000, Maximum=33.980, Mean=-15887.345, StdDev=16386.592
   256 buckets from -32831.1 to 98.0444:
   1545169 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 27375 1924356
   NoData Value=-32767
   Metadata:
     STATISTICS_MAXIMUM=33.979999542236
     STATISTICS_MEAN=-15887.344614501
     STATISTICS_MINIMUM=-32767
     STATISTICS_STDDEV=16386.59208246


It seems that the NoData value is included in the stats which really 
skews the numbers compressing all my values into two buckets! How can I 
avoid that? I want to ignore the NoData values and spread my good values 
into the remaining buckets. How can I do this?

Thanks,
   -Steve



More information about the gdal-dev mailing list