<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:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.Shkpostityyli18
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.std
{mso-style-name:std;}
span.Shkpostityyli21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:419062035;
mso-list-template-ids:-1188126756;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:"Courier New";
mso-bidi-font-family:"Times New Roman";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l1
{mso-list-id:862323164;
mso-list-template-ids:-273615392;}
@list l1:level1
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level2
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level3
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level5
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level6
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level8
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level9
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></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="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">You have an interesting theoretical challenge but I would still make it in another way. First, it would be easier to use single band 16-bit png instead of 3-band 8-bit png. And second, compressed
tiff is not much bigger than png. Use the deflate method which is the same method that png is using. For DEMs I would recommend to use the option “predictor=2”.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">Here are numbers from a quick test with 16-bit DEM file.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">gdal_translate -of GTiff -co compress=deflate –co tiled=yes -co predictor=2 dem.png dem.tif<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">png: 1326381 bytes<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">tiff: 1394597 bytes<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">Tiled tiff with overviews added with the gdaladdo utility is also much better (=faster) format for MapServer that png files. Overviews add 25% to the file size but it is worth it.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="mso-fareast-language:FI">Lähettäjä:</span></b><span lang="EN-US" style="mso-fareast-language:FI"> mapserver-users [mailto:mapserver-users-bounces@lists.osgeo.org]
<b>Puolesta </b>Tellez-Arenas Agnes<br>
<b>Lähetetty:</b> 4. tammikuuta 2018 16:40<br>
<b>Vastaanottaja:</b> mapserver-users@lists.osgeo.org<br>
<b>Aihe:</b> [mapserver-users] Classification of RGB png (or tiff) using [red] [green] [blue]<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Dear all,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I am trying to classify a PNG (could be a tiff) which has the 3 bands (red, green, blue), each from 0..255.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I need to classify (not just display it as it is), because I have used those 3 bands to “code” elevation values (it’s a hightmap).
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">I am using a PNG to encode the elevation value on those r,g,b bands, rather than one tiff containing directly the elevation on the pixel, because the size of the PNG is smaller than tiff (and I need to store a big amount
of images…).<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The formula to “encode” the elevation is<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><i><span lang="FR">#min=-50, max=1000 ((r * 256 + g + b / 256) * (Zmax-Zmin)/(65536)) + Zmin*
<o:p></o:p></span></i></p>
<p class="MsoNormal" style="text-indent:35.4pt"><i><span lang="EN-US">Which I translated as<o:p></o:p></span></i></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-indent:35.4pt"><i><span lang="EN-US">CLASS #min=-50, max=1000 ((r * 256 + g + b / 256) * (Zmax-Zmin)/(65536)) + Zmin*<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> EXPRESSION ( ((( (red]*256) +[green] +([blue]/256)) * (1050/65536)) - 50) <= 0)
<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> STYLE<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> COLOR 100 195 215<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> OPACITY 35<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> END<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> END
<o:p></o:p></span></i></p>
<p class="MsoNormal"><span lang="EN-US">But, [red]=[green]=[blue]= the value of the first band (red). Always.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">In documentation I can see (<a href="http://mapserver.org/mapfile/expressions.html">http://mapserver.org/mapfile/expressions.html</a>)<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><i><span lang="EN-US" style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:FR">For
</span></i><i><span lang="FR" style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:FR"><a href="http://mapserver.org/input/raster.html#raster"><span lang="EN-US" style="color:blue">Raster Data</span></a></span></i><i><span lang="EN-US" style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:FR">
layers special attributes have been defined that can be used for classification, for example:<o:p></o:p></span></i></p>
<ul type="disc">
<li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3">
<i><span lang="EN-US" style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:FR">[PIXEL] ... will become the pixel value as number<o:p></o:p></span></i></li><li class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3">
<i><span lang="EN-US" style="font-size:12.0pt;font-family:"Times New Roman",serif;mso-fareast-language:FR">[RED], [GREEN], [BLUE] ... will become the color value for the red, green and blue component in the pixel value, respectively.<o:p></o:p></span></i></li></ul>
<p class="MsoNormal"><span lang="EN-US">And (<a href="http://mapserver.org/el/input/raster.html">http://mapserver.org/el/input/raster.html</a>)<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><i><span lang="EN-US">There is no need to specify a
</span></i><cite><span lang="EN-US" style="font-family:"Calibri",sans-serif;font-style:normal">CLASSITEM</span></cite><i><span lang="EN-US">. The raw pixel value itself (“[pixel]”) and, for paletted images, the red, green and blue color associated with that
pixel value (“[red]”, “[green]” and “[blue]”) are available for use in classifications.<o:p></o:p></span></i></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Hope someone can help me on that!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks!<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Here is my MapFile.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">MAP<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> NAME "test"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> STATUS OFF<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> SIZE 256 256<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> MAXSIZE 4096<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> RESOLUTION 96
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> EXTENT 253999.500 6884000.500 254999.500 6885000.500<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> UNITS DD <o:p>
</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> IMAGETYPE png<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> IMAGECOLOR 255 255 255<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span lang="EN-US">PROJECTION<o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span lang="EN-US"> "init=epsg:2154"
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> END<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> WEB<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> TEMPLATE "../etc/html_template/getcapabilities_wms_130.html"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> METADATA<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> (…)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> END<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> END<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> LAYER<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> NAME "test"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> TYPE RASTER <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> DATA "/mnt/nemesis_resultats/flood/v3/v4_1m/RGEALTI_FXX_0224_6753_MNT_LAMB93_IGN69_png.png"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> #PROCESSING "BANDS=1,2,3" #this line crashes with a “drawGDAL(): Unable to access file. Attempt to classify 24bit image, this is unsupported.”<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> STATUS ON<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> PROJECTION<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> "init=epsg:2154"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> END<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> METADATA<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> (…)
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> END<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> CLASS #min=-50, max=1000 ((r * 256 + g + b / 256) * (Zmax-Zmin)/(65536)) + Zmin*<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> EXPRESSION ( ((( (red]*256) +[green] +([blue]/256)) * (1050/65536)) - 50) <= 0)
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> STYLE<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> COLOR 100 195 215<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> OPACITY 35<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> END<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> END <o:p>
</o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> END #LAYER<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"> <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">END <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="FR"># End of MapFile<o:p></o:p></span></p>
</div>
</body>
</html>