Coloring Mapserver Floating Tiffs with Colorscales

This has been a little mystery for me waiting to be uncovered. However I solved it. Depending if you are using a SLD (styled layer descriptor) or the embedded Style commands this is what your Mapfile could look like:

MAP
NAME "Some Map"
DEBUG ON
FONTSET "/home/fritz/maps/fonts.txt"

WEB
  IMAGEPATH "/tmp/"
  IMAGEURL "/tmp/"
  METADATA
    "wms_title"     "WMS Demo Server"  ##required
    "wms_onlineresource" "http://localhost/cgi-bin/mapserv?map=map.map"   ##required
    "wms_srs"       "EPSG:42304 EPSG:42101 EPSG:4269 EPSG:4326 EPSG:7030 EPSG:32736"  ##recommended
  END
END

PROJECTION
  "init=epsg:32736"   ##required
END

#
# Start of layer definitions
#
LAYER
NAME 'test'
METADATA
    "wms_title"   'test'
END
TYPE RASTER
STATUS ON
DATA  '/home/fritz/maps/colorscale_test.tif'
PROJECTION
  "init=epsg:32736"   ##required
END
CLASS
  NAME "test"
  STYLE
    COLORRANGE 255 255 0 140 160 160
    DATARANGE 0.02 0.6
    RANGEITEM "[pixel]"
  END
END
PROCESSING "SCALE=0.2, 0.6"
END

The Scale and Datarange command look very similar and I haven’t figured out quite how to set it properly, or how to have three-color scale. However it’s a start. And I haven’t found it documented anywhere else, here you go.


Words by fritzvd

comments powered by Disqus