Outputting 8-bit GeoTIFF with PCT: extra entry?

Frank Warmerdam warmerdam at POBOX.COM
Wed Mar 1 15:31:16 PST 2006


Avi A Blackmore wrote:
> Hi there,
> 
> 	I'm working on a raster density-slicing application using Mapserver 4.6.0, which classifies the pixels into discrete "zones" based on the range
> of pixel values.  What I'm shooting for is a single band GeoTIFF, whose raster cell values are either 0 (meaning "no data") or a number corresponding
> to the zone that the source cell was classified as by Mapserver, and then a color table entry which corresponds to the zone's coloring in the style object.
> 
> 	That is, if I sliced an NIR satellite image into 7 zones, what I want is for the raster cells to have values 1-7, and color table entries 0-7 to be filled with
> the corresponding color for that class (or the OFFSITE color for values of 0).  This way, an application can determine the zone just by reading the raster cell value.
> 
> 	What I get, however, is a raster whose cells have values 2-8, with the color table entries 2-8 having the zone color values, and color table entry 1 being set
> to 0, 0, 0.  GDAL in Python reports that the resulting raster does not have any pixels with value of 1: the values are either 0 or 2-8.  This effect shows up regardless
> of the number of zones I slice the image into: at 30 zones, I get color table entries 0-31 filled, with this spurious "black" at entry 1.  I have checked carefully, the number
> of classes in the raster layer, and they always match exactly the number of zones.
> 
> 	So, what's going on here?  I'm using the GDAL output driver to write the GeoTIFFs.  I'm not sure if there is any other information that might be useful or necessary.

Avi,

There are a number of reasons various color cells can get allocated by
MapServer whether used or not.  I *suspect* 0,0,0 is your background
color and (IMAGECOLOR on the map object, implicit or explicit).  You might
want to try setting that to one of your class colors to avoid it being
allocated separately.

The problem you are running into is basically why MapServer in pseudocolor
WMS or normal map drawing mode is not very suitable for serving raw data.
It does too much fooling around allocating colors and remapping them as
things are drawn.   But, you might just fiddle with things to get it working.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGF, http://osgeo.org



More information about the MapServer-users mailing list