[MapServer-users] How to use OPACITY and COLOR in STYLE for raster float32 data
Trygve Aspenes
trygve at aspenes.priv.no
Wed Feb 26 06:26:39 PST 2025
I have raster data with float32 data.
To colorize this I have defined several CLASSES each with a STYLE for a
specific interval of float values.
eg:
CLASS
NAME "no meassure"
GROUP "this-palette"
EXPRESSION ([pixel] >= 0 and [pixel] < 0.03)
STYLE
COLOR 190 190 190
OPACITY 5
END # STYLE
END # CLASS
and onvards for increasing pixel values.
This works ok, but I dont understand what happens to this color (as
given in the CLASS above) in the resulting png image from a getMap
request.
The provided link is the png produced by a getMap request with the given
style.
If you look closely the large area between the bluish areas should have
the style as given above. However if I display the image with display
these pixels have values 54 54 54 0.129412
https://drive.google.com/file/d/1pof5BQoR3vzIo6KRvOmEtjgBMeZehCy_/view?usp=sharing
(just clicking the link will not show this I think, you have to download
it and view it in some viewer which can provide pixel details or a
screenshot is provided here
https://drive.google.com/file/d/1IOgkvwCtfHAEL2jCGhe9arhoI26D-MRV/view?usp=sharing
So my question is: How on earth can the given style with color 190 190
190 and opacity 5 become 54 54 54 0.129412?
Opacity is a integer between 0 and 100 ( as in percent?) and some
scaling is done by the mapserver code to get to alpha (between 0 and
255)
https://github.com/MapServer/MapServer/blob/main/src/mapfile.c#L2797-L2806
But If I give Opacity 5 I would expect to get something like 0.02.
Trygve
More information about the MapServer-users
mailing list