[Mapserver-users] GeoTIFF Summary

Frank Warmerdam warmerdam at pobox.com
Thu Feb 19 00:40:39 EST 2004


Rolf Becker wrote:
> S1) ... all raster data are mapped (classified) to 0..255 before drawing 
> (drawGDAL()).

Rolf,

This is true currently.  But note, this is on a band-by-band basis.
If you have a 24bit RGB file (3 8bit bands) the 8bit bands don't need
any scaling action to reduce them to 0...255.  This only kicks in for
non-8bit bands.

> Q1) How are the 3 bands with 256 values each mapped to one dimension, 
> i.e. 0-255, by mapserver?

If your output is a pseudocolored 8bit image (ie one band with a color
table, like gif or some pngs files -- see PC256 mode in OUTPUTFORMAT) then
some mechanism is required to reduce the RGB image with (in theory) 64M
colors to 256.  The default mechanism is to apply setup a color cube
with 5 levels of red, 7 of green and 5 of blue (175 colors).  Then each
RGB pixel is mapped to the nearest color (or the nearest after error
diffusion if that is turned on).

> S2) ... values above 255 are clipped to 255.

If scaling is disabled then values below 0 are mapped to 0, and above
255 are mapped to 255.  If scaling is turned on (by processing directive)
then a linear stretch is applied.

> S3) ... one solution is to preprocess data before feeding into mapserver.

Right.  A very good option if you want speed and control, and don't need
things done on-the-fly from the live data every time.

> S4) ... a second solution is to use the PROCESSING directive in the 
> map-file.

PROCESSING options can control scaling, whether dithering is used,
and some stuff about how close a color needs to be when deciding whether
to try to allocate a new one.  It can't (currently) control the resolution
of the color cube.

> Q2) Are these the only solutions?

Pretty much, for dynamic conversion at least.  I am ignoring use of
clasification, as it can't be applied to multi-band (ie 24bit RGB)
input files as far as I know.  I could be wrong about this.

> Q3) Is it possible to set exact one class (e.g. [pixel]=255) to 
> transparent (unvisible)?

The OFFSITE keyword can be used to indicate an RGB tuple to be treated
as transparent (nodata).

> Q4) Without an explicit classification in the map-file (CLASS ... END) 
> the TIFF looks nice in its default colors, which looks like an implicit 
> classification to me. If I introduce one explicit class which does not 
> cover the whole value range (co-domain) of the pixel values, e.g. 
> [pixel]<10, I will have to explicitly classify the rest of the values 
> (>=10), otherwise pixels with unclassified values won't be drawn. Is 
> this correct? Is it possible to classify only part of the values and to 
> use the default (implicit) classification for the rest?

Are you sure the file is 24bit RGB (3 band)?

I didn't think classifcation worked at all for RGB input files.  It might
be that it just kicks into a mode where only the first band is used though.

I've re-read the logic in the code, and it seems like it will currently issue
an "Attempt to classify 24bit image, this is unsupported." error message if you
try to classify an RGB input.  Perhaps there is something else going on too.

> Q5) My GeoTIFF (tct.tif, tct.tfw, with 3 bands) is drawn with this piece 
> of map-file code:
> 
> LAYER
>   NAME "tct"
>   TYPE RASTER
>   STATUS ON
>   TILEINDEX "tct_index.shp"
>   TILEITEM "Location"
> END
> 
> in perfect colors!!! Very nice.
> 
> The same file will not appear if I use the following code:
> 
> LAYER
>   NAME "tct"
>   TYPE RASTER
>   STATUS ON
>   DATA "/home/data/map/sulm_data/iwk_data/tctstdverwsul.tif"
> END
> 
> Why?

I don't know.  Have you done the usual debugging steps?

   http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?DebuggingMapserver

The most likely reason is that your path is wrong, permissions are wrong,
your extents are wrong in some way or the non-GDAL TIFF draw code is
kicking in.  The raster rendering of a file in the tile index operates
essentially the same as a raster directly specified.

> Q6) If I use the map-file fragment
> 
> LAYER
>   NAME "tct"
>   TYPE RASTER
>   STATUS ON
>   PROCESSING "BANDS=2"
>   DATA "/home/data/map/sulm_data/iwk_data/tctstdverwsul.tif"
> END
> 
> I will get a gray scale image which is deemed to be band 2 of the 
> GeoTIFF (who knows :).
> 
> But what is the directive PROCESSING "BANDS=1,2,3" for? Isn't it 
> worthless? It simply crashes the application with the following warning:
> Warning: [MapServer Error]: drawGDAL(): Attempt to classify 24bit image, 
> this is unsupported.

This shouldn't be a crash.  It should be an orderly application termination
with a runtime error. :-)

Did you have any CLASS declarations with BANDS=1,2,3?  As noted earlier
this is not a supported configuration.

> Q7) What is planned in future concerning the current classification scheme?

Non-8bit data classification should be implemented in the near future.
That is, being able to classify a single band raster with values outside
the range 0...255 without-prescaling.

> Q8) Will floating point values for rasters be supported?

They are now with scaling/clipping.  They will be supported for direct
use in classification in the near future.

> Q9) Somewhere in the mail archieve I stumbled across a trick how to 
> query data from raster data but I can't find it anymore. Could you 
> please give me a hint or the url?

I don't think there is a mapserver way to do this.  Perhaps this was
Charlton Purvis' imaginative work around?  I don't have it handy, but if
you search on his name you should find it.

I do hope to implement proper raster query support in line with the way
vector queries work at some point fairly soon.

> Q10) What about an update of the FAQ?

What about it? Gee, it does look kind of out of date doesn't it.   My
personal opinion is that the FAQ would be better maintained in the wiki
so it can be more dynamic.

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    | Geospatial Programmer for Rent




More information about the mapserver-users mailing list