<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML-esimuotoiltu Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTML-esimuotoiltuChar
        {mso-style-name:"HTML-esimuotoiltu Char";
        mso-style-priority:99;
        mso-style-link:HTML-esimuotoiltu;
        font-family:Consolas;
        mso-fareast-language:FI;}
span.Shkpostityyli21
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 2.0cm 70.85pt 2.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FI" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">What is your nodata value and the datatype of the source raster? If you deal with byte or int16 data and the nodata value is 0, you can keep it unaltered in your LUT, then map values
 1-9 into 1 that is almost black, range 10-19 as you wish, and 20 and above into white.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>Lähettäjä:</b> Mallinger, Bernhard <bernhard.mallinger@eox.at>
<br>
<b>Lähetetty:</b> maanantai 28. marraskuuta 2022 16.53<br>
<b>Vastaanottaja:</b> Rahkonen Jukka <jukka.rahkonen@maanmittauslaitos.fi><br>
<b>Kopio:</b> mapserver-users@lists.osgeo.org<br>
<b>Aihe:</b> Re: [MapServer-users] Distinguish between pixels outside of SCALE range and nodata pixels<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Thank you for the suggestion, I have tried it now.<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Since the values below the minimum scale is mapped to 0, i tried using the following instruction:<br>
<br>
PROCESSING "LUT=0:1"<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">This actually maps the values below the minimum to 1, but also the no data values. Do you know if there's a way where I can distinguish between those two using LUT?<o:p></o:p></p>
</div>
<p class="MsoNormal">Best,<o:p></o:p></p>
</div>
<p class="MsoNormal">Bernhard<o:p></o:p></p>
<div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Mon, Nov 28, 2022 at 3:26 PM Rahkonen Jukka <<a href="mailto:jukka.rahkonen@maanmittauslaitos.fi" target="_blank">jukka.rahkonen@maanmittauslaitos.fi</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi,<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span lang="EN-US">Have you tried the LUT processing option
<a href="https://eur06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fmapserver.org%2Finput%2Fraster.html&data=05%7C01%7Cjukka.rahkonen%40maanmittauslaitos.fi%7C046212920572444ef6f008dad1504c07%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C0%7C638052440048006207%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hvl4h66%2BfJZhlIiyZKx10SqqwPXyFdyfIZgEooRMqjY%3D&reserved=0" target="_blank">
https://mapserver.org/input/raster.html</a>?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span lang="EN-US"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span lang="EN-US">-Jukka Rahkonen-</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span lang="EN-US"> </span><o:p></o:p></p>
<div style="border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0cm 0cm 0cm;border-color:currentcolor currentcolor">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b>Lähettäjä:</b> MapServer-users <<a href="mailto:mapserver-users-bounces@lists.osgeo.org" target="_blank">mapserver-users-bounces@lists.osgeo.org</a>>
<b>Puolesta </b>Mallinger, Bernhard<br>
<b>Lähetetty:</b> maanantai 28. marraskuuta 2022 15.35<br>
<b>Vastaanottaja:</b> <a href="mailto:mapserver-users@lists.osgeo.org" target="_blank">
mapserver-users@lists.osgeo.org</a><br>
<b>Aihe:</b> [MapServer-users] Distinguish between pixels outside of SCALE range and nodata pixels<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt">Hello,<o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">We have maps where we want the color scale go from e.g. 10 to 20, so we are using this directive:<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt"><br>
<span style="font-family:"Courier New"">PROCESSING "SCALE_1=10.0,20.0" </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt">So the behaviour we would like is that values below 10 are rendered as black and values over 20 are rendered as white.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Is this somehow possible with mapscript?<br>
<br>
<br>
We tried to have a look in the source code, and there is this line, which effectively assigns 0 to pixels below the minimum:<br>
<a href="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%7C046212920572444ef6f008dad1504c07%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C0%7C638052440048006207%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=eGNr6SWL6I0yQbse%2F5SAuV7QjISOBoyi30BxYB13C9Y%3D&reserved=0" target="_blank">https://github.com/MapServer/MapServer/blob/main/mapdrawgdal.c#L1555</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">It turns out that this small code change actually produces the desired behavior:<o:p></o:p></p>
</div>
<div>
<pre id="m_5106503157384725565m_-2264963374138121724gmail-code-7">       fScaledValue = (float) ((pafRawData[i]-dfScaleMin)*dfScaleRatio);<o:p></o:p></pre>
<pre> <o:p></o:p></pre>
<pre>       if( fScaledValue < 0.0 )<o:p></o:p></pre>
<pre>-        pabyBuffer[i] = 0;<o:p></o:p></pre>
<pre>+        if (pafRawData[i] > 0) {<o:p></o:p></pre>
<pre>+            pabyBuffer[i] = 1;<o:p></o:p></pre>
<pre>+        } else {<o:p></o:p></pre>
<pre>+            pabyBuffer[i] = 0;<o:p></o:p></pre>
<pre style="margin-bottom:12.0pt">+        }<o:p></o:p></pre>
<pre style="margin-bottom:12.0pt" id="m_5106503157384725565m_-2264963374138121724gmail-code-7"><span style="font-family:"Arial",sans-serif">(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.)</span><o:p></o:p></pre>
<pre style="margin-bottom:12.0pt" id="m_5106503157384725565m_-2264963374138121724gmail-code-7"><span style="font-family:"Arial",sans-serif">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.<br>Do you have any thoughts on this? Does this make sense to you as a feature?</span><o:p></o:p></pre>
<pre id="m_5106503157384725565m_-2264963374138121724gmail-code-7"><span style="font-family:"Arial",sans-serif">Best regards,<br>Bernhard</span><o:p></o:p></pre>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>