<div dir="ltr">I assume it would read the data twice.<br><br>I suppose the other option is to abandon the PROCESSING SCALE directive entirely.  Set all your CLASS colors for 10.0 to 20.0 manually.  It can be tedious to set up, but we do this all the time for scales with 200+ custom colors.  Then you are free to keep the  "< 10 black" and  "> 20 white" classes in the same layer.<div><br></div><div>[pixel] < 10   black<br></div><div>[pixel] < 10.1   </div><div>[pixel] <10.2</div><div>...</div><div>[pixel] < 20</div><div>[pixel] >= 20   white</div><div><br></div><div>For readability purposes, I'd put that big collection of classes in a separate file, and use  #INCLUDE  to bring it into the LAYER section of the mapfile.<br><br><div>-Tim</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 28, 2022 at 9:51 AM Mallinger, Bernhard <<a href="mailto:bernhard.mallinger@eox.at">bernhard.mallinger@eox.at</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>Thank you for the suggestion, this actually achieves the desired effect!<br></div><br>I'm just wondering if this now reads the data twice?<br><br></div><div>We're using data from remote locations which can be slow to read, so reading them twice would be inconvenient.<br><br></div><div>Best,<br></div><div>Bernhard<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 28, 2022 at 3:18 PM Timothy Kempisty - NOAA Federal <<a href="mailto:timothy.kempisty@noaa.gov" target="_blank">timothy.kempisty@noaa.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Try adding a separate background layer using the same data, with CLASS statements only for your out of bounds pixel values.  Simplified a bit here:<div><br></div><div><div><span style="font-family:monospace">LAYER</span></div><div><span style="font-family:monospace">    # -- Your existing layer</span></div><div><span style="font-family:monospace">    NAME my_actual_data</span></div><div><b style="font-family:monospace">    GROUP mydata</b></div><div><span style="font-family:monospace">    DATA same_data</span></div><div><span style="font-family:monospace">    </span><span style="font-family:monospace">PROCESSING "SCALE_1=10.0,20.0"</span><br></div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">    <... yadda yadda ...></span><br></div><div><span style="font-family:monospace">END</span><br></div><br></div><div><font face="monospace">LAYER</font></div><div><div><font face="monospace"># -- New layer adds black/white colors where pixel values exceed scale bounds</font></div><div></div></div><div><font face="monospace">   NAME background</font></div><div><font face="monospace"><b>   GROUP mydata</b></font></div><div><font face="monospace">   DATA same_data</font></div><div><div><font face="monospace">      CLASS</font></div><div><font face="monospace">          EXPRESSION ([pixel] < 10)</font></div><div><font face="monospace">              <...black...></font></div><div><font face="monospace">      END</font></div><div><font face="monospace">      CLASS</font></div><div><font face="monospace">          EXPRESSION </font><span style="font-family:monospace">([pixel] > 20)</span></div><div><span style="font-family:monospace">              <...white...></span></div><div><span style="font-family:monospace">      END</span></div><div><span style="font-family:monospace">END</span></div><div><span style="font-family:monospace"><br></span></div><div>Display both layers together by requesting the "mydata" group name, just like you would request any other layer.  It will render all layers with the same group name.<br></div></div><div><br></div><div>-Tim<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 28, 2022 at 8:35 AM Mallinger, Bernhard <<a href="mailto:bernhard.mallinger@eox.at" target="_blank">bernhard.mallinger@eox.at</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello,<br><br></div>We have maps where we want the color scale go from e.g. 10 to 20, so we are using this directive:<br><div><br><span style="font-family:monospace">PROCESSING "SCALE_1=10.0,20.0" </span><br><br></div><div>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.<br><br></div><div>So the behaviour we would like is that values below 10 are rendered as black and values over 20 are rendered as white.<br><br></div><div>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://github.com/MapServer/MapServer/blob/main/mapdrawgdal.c#L1555" target="_blank">https://github.com/MapServer/MapServer/blob/main/mapdrawgdal.c#L1555</a></div><div><br></div><div>It turns out that this small code change actually produces the desired behavior:<br></div><div><pre id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-code-7" lang="plaintext"><code><span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC1" lang="plaintext">       fScaledValue = (float) ((pafRawData[i]-dfScaleMin)*dfScaleRatio);</span>
<span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC2" lang="plaintext"> </span>
<span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC3" lang="plaintext">       if( fScaledValue < 0.0 )</span>
<span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC4" lang="plaintext">-        pabyBuffer[i] = 0;</span>
<span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC5" lang="plaintext">+        if (pafRawData[i] > 0) {</span>
<span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC6" lang="plaintext">+            pabyBuffer[i] = 1;</span>
<span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC7" lang="plaintext">+        } else {</span>
<span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC8" lang="plaintext">+            pabyBuffer[i] = 0;</span>
<span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC9" lang="plaintext">+        }<br><br></span></code></pre><pre id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-code-7" lang="plaintext"><code><span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC9" lang="plaintext"><font face="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.)<br><br></font></span></code></pre><pre id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-code-7" lang="plaintext"><code><span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC9" lang="plaintext"><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?<br><br></span></span></code></pre><pre id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-code-7" lang="plaintext"><code><span id="m_-5384704860540628421m_4625277349163618871m_-3358362255204072230gmail-LC9" lang="plaintext"><span style="font-family:arial,sans-serif">Best regards,<br>Bernhard</span><br></span></code></pre></div></div>
_______________________________________________<br>
MapServer-users mailing list<br>
<a href="mailto:MapServer-users@lists.osgeo.org" target="_blank">MapServer-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>