[mapserver-users] raster gradient using python mapscript and postgis

Pasithee Jupiter pasithee at gmail.com
Thu Jan 23 23:41:01 PST 2014


Hi All

I'm trying to use mapscript Python bindings to create a gradient on a
raster coming from PostGIS.
My Source looks like the following.

...

map_class = mapscript.classObj()


map_class.name = "test"

map_class.setExpression("([pixel] >= 0 AND [pixel] <= 1000)")


map_style = mapscript.styleObj()

map_style.rangeitem = "[pixel]"

map_style.maxcolor.setRGB(250, 250, 210)

map_style.mincolor.setRGB(178, 34, 34)

map_style.minvalue = 0

map_style.maxvalue = 1000


map_class.insertStyle(map_style)

layer.insertClass(map_class)

...


and the generated mapfile like this:


...
    STATUS ON
    TILEITEM "location"
    TYPE RASTER
    UNITS METERS
    CLASS
      NAME "test"
      EXPRESSION ([pixel] >= 0 AND [pixel] <= 1000)
      STYLE
        RANGEITEM "[pixel]"
        COLORRANGE 178 34 34  250 250 210
        DATARANGE 0 1000
      END # STYLE
    END # CLASS
  END # LAYER
...


The Problem is, that the gradient is never applied to the raster file. Here
(http://lists.osgeo.org/pipermail/mapserver-users/2011-November/070820.html)
the *RANGEITEM* is not set, but here (
http://mapserver.org/development/rfc/ms-rfc-6.html) they write that the
*RANGEITEM* is mandatory. So

   - when I try to remove that *RANGEITEM* in the Python source, then the
   STYLE section would be empty
   - when I add it using the value *[pixel]* or *pixel,* the gradient is
   never applied to the raster

Does anyone has an idea what I'm doing wrong?

Thanks a lot for any help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20140124/bb7cee7e/attachment.htm>


More information about the MapServer-users mailing list