Hi,

Have you tried the LUT processing option 
https://mapserver.org/input/raster.html?

-Jukka Rahkonen-

Lähettäjä: MapServer-users <[email protected]> Puolesta 
Mallinger, Bernhard
Lähetetty: maanantai 28. marraskuuta 2022 15.35
Vastaanottaja: [email protected]
Aihe: [MapServer-users] Distinguish between pixels outside of SCALE range and 
nodata pixels

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<https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMapServer%2FMapServer%2Fblob%2Fmain%2Fmapdrawgdal.c%23L1555&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7Cc759129ba15f4a44e03d08dad1456ef8%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C0%7C638052393387117846%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=t6zAXKjbvlaZx5FiDt3lPMGBui7IshCIXHLiBdxXSBk%3D&reserved=0>

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
_______________________________________________
MapServer-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to