[mapserver-users] About the Color Ramp for Raster Data

Yves Jacolin (Free) yjacolin at free.fr
Thu Jun 27 01:19:37 PDT 2013


Guo,

Here is a working example:

  LAYER
    NAME "example"
    TYPE RASTER
    STATUS ON
    DUMP TRUE
    PROCESSING "BANDS=1"
    DATA geotif.tif
    PROJECTION
       "init=epsg:4326"
    END
    EXTENT -40 -90 40 -45
    CLASSITEM "[pixel]"
	# blue to yellow
    CLASS
      NAME "colorramp"
      EXPRESSION ([pixel] >= 0 AND [pixel] < 1.5)
      STYLE
        COLOR -1 -1 -1
        COLORRANGE 38 76 255 255 255 191
        DATARANGE 0.0 1.5
        RANGEITEM "foobar"
      END
    END
	# yellow to dark red
    CLASS
      EXPRESSION ([pixel] >= 1.5 AND [pixel] <= 3.0)
      STYLE
        COLOR -1 -1 -1 
        COLORRANGE 255 255 191 94 0 18 
        DATARANGE 1.5 3.0
        RANGEITEM "foobar"
      END
    END
#	# light red to dark red
#    CLASS
#      EXPRESSION ([pixel] > 2.394 AND [pixel] < 3.189)
#      STYLE
#        COLOR -1 -1 -1
#        COLORRANGE 247 109 94 94 0 18
#        DATARANGE 2.394 3.189
#        RANGEITEM "foobar"
#      END
#    END
    METADATA
       "wms_title" "example"
       "wms_srs"   "EPSG:4326"
    END
  END

I don't think that php/mapscript could be used for this kind of raster class 
:/

Regards,

Y.
Le mercredi 26 juin 2013 23:07:16 Guo YU a écrit :
> Dear Yves,
>       Thanks for your reply. Could you give me an example on that. I tried
> several times, but it doesn't work. I think maybe I put it in the wrong
> location. It should be inside the Layer->Class level, right? Anyway, a
> mapfile example can give me good clue.
>       Another question, is it work in PHP_Mapscript? I also tried to get
> that work but it failed. It seems the PHP-Mapscript doesn't know what is
> colorrange. So every time I save the map object as a mapfile, the
> colorrange is omitted.
> 
>        Thanks.
> 
> On Wed, Jun 26, 2013 at 11:05 AM, Yves Jacolin (Free) 
<yjacolin at free.fr>wrote:
> > Le mercredi 26 juin 2013 11:03:10 Guo YU a écrit :
> > > Does this proposed new syntax work yet?
> > > http://mapserver.org/development/rfc/ms-rfc-6.html#proposed-new-syntax
> > > 
> > > Currently, I am still using this method for rendering the color. However
> > 
> > it
> > 
> > > doesn't work so well since it is linear interpolation and equal
> > > interval.
> > > In reality, the histogram of raster shows that data doesn't distribute
> > 
> > with
> > 
> > > equal interval. In ArcGIS, the default method for classified raster
> > > rendering is Natural Breaks (Jenks).
> > > 
> > > 
> > > STYLE
> > > 
> > >   COLORRANGE 0 0 0  255 255 0 # black to yellow
> > >   DATARANGE 0.0 100.0
> > >   RANGEITEM "foobar"
> > > 
> > > END
> > > 
> > > Is there any new improvement for that in MapServer? Thanks
> > 
> > Hello,
> > 
> > It is working well as we are using it. Even if it could be improved (add
> > legend support for instance) :)
> > 
> > Anyway, you can use EXPRESSION parameter for each CLASS you need to do
> > what
> > you want.
> > 
> > Regards,
> > 
> > Y.
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the MapServer-users mailing list