[MapServer-users] Distinguish between pixels outside of SCALE range and nodata pixels

Mallinger, Bernhard bernhard.mallinger at eox.at
Mon Nov 28 05:35:06 PST 2022


Hello,

We have maps where we want the color scale go from e.g. 10 to 20, so we are
using this directive:

PROCESSING "SCALE_1=10.0,20.0"

This works great by itself, however it also means that pixels with values
of e.g. 5 are rendered as transparent, which is the same as the nodata
pixels. So in the final image, you can't tell if data is present but the
values are too low, or if there just isn't any data.

So the behaviour we would like is that values below 10 are rendered as
black and values over 20 are rendered as white.

Is this somehow possible with mapscript?


We tried to have a look in the source code, and there is this line, which
effectively assigns 0 to pixels below the minimum:
https://github.com/MapServer/MapServer/blob/main/mapdrawgdal.c#L1555

It turns out that this small code change actually produces the desired
behavior:

       fScaledValue = (float)
((pafRawData[i]-dfScaleMin)*dfScaleRatio);        if( fScaledValue <
0.0 )-        pabyBuffer[i] = 0;+        if (pafRawData[i] > 0) {+
       pabyBuffer[i] = 1;+        } else {+            pabyBuffer[i] =
0;+        }

(I.e. if the original value was greater than 0, then assign 1 to this
pixel such that it will be black and not transparent.)

If this behavior can't yet be configured via mapscript, we could work
on a pull request to implement this behavior, which would then be
activated via a new configuration option.
Do you have any thoughts on this? Does this make sense to you as a feature?

Best regards,
Bernhard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20221128/1d8c8346/attachment-0001.htm>


More information about the MapServer-users mailing list