[mapserver-users] Classification of RGB png (or tiff) using [red] [green] [blue]

Tellez-Arenas Agnes a.tellez-arenas at brgm.fr
Thu Jan 4 06:39:34 PST 2018


Dear all,

I am trying to classify a PNG (could be a tiff) which has the 3 bands (red, green, blue), each from 0..255.
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).

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...).
The formula to "encode" the elevation is
#min=-50, max=1000 ((r * 256 + g + b / 256) *  (Zmax-Zmin)/(65536)) + Zmin*
Which I translated as
CLASS #min=-50, max=1000 ((r * 256 + g + b / 256) *  (Zmax-Zmin)/(65536)) + Zmin*
                                               EXPRESSION ( ((( (red]*256) +[green] +([blue]/256)) * (1050/65536)) - 50) <= 0)
                                               STYLE
                                                               COLOR 100 195 215
                                                               OPACITY 35
                                               END
                               END
But, [red]=[green]=[blue]= the value of the first band (red). Always.

In documentation I can see (http://mapserver.org/mapfile/expressions.html)
For Raster Data<http://mapserver.org/input/raster.html#raster> layers special attributes have been defined that can be used for classification, for example:

  *   [PIXEL] ... will become the pixel value as number
  *   [RED], [GREEN], [BLUE] ... will become the color value for the red, green and blue component in the pixel value, respectively.
And (http://mapserver.org/el/input/raster.html)
There is no need to specify a CLASSITEM. 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.

Hope someone can help me on that!
Thanks!


Here is my MapFile.

MAP
                NAME "test"
                STATUS OFF
                SIZE 256 256
                MAXSIZE 4096
                RESOLUTION 96
                EXTENT 253999.500 6884000.500 254999.500 6885000.500
                UNITS DD
                IMAGETYPE png
                IMAGECOLOR 255 255 255
PROJECTION
        "init=epsg:2154"
             END
                WEB
                               TEMPLATE "../etc/html_template/getcapabilities_wms_130.html"
                               METADATA
                               (...)
                               END
                END

                LAYER
                  NAME  "test"
                 TYPE   RASTER
                  DATA   "/mnt/nemesis_resultats/flood/v3/v4_1m/RGEALTI_FXX_0224_6753_MNT_LAMB93_IGN69_png.png"
                  #PROCESSING "BANDS=1,2,3" #this line crashes with a "drawGDAL(): Unable to access file. Attempt to classify 24bit image, this is unsupported."

                  STATUS ON
                  PROJECTION
                     "init=epsg:2154"
                  END
                  METADATA
                                (...)
                  END

                               CLASS #min=-50, max=1000 ((r * 256 + g + b / 256) *  (Zmax-Zmin)/(65536)) + Zmin*
                                               EXPRESSION ( ((( (red]*256) +[green] +([blue]/256)) * (1050/65536)) - 50) <= 0)
                                               STYLE
                                                               COLOR 100 195 215
                                                               OPACITY 35
                                               END
                               END


                END #LAYER

END
# End of MapFile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20180104/5929a0d3/attachment-0001.html>


More information about the mapserver-users mailing list