[mapserver-users] Trouble coloring a raster

Stephen Woodbridge woodbri at swoodbridge.com
Tue Mar 5 12:27:13 PST 2013


Bob,

There is no code to do what you are expecting. Basically, COLOR is used 
for vector objects that do not have the ability to specify a color in 
most cases. Raster data implicitly defines a color by virtue of the 
pixel values. I fyou don't like the color of the raster that you have 
you have to reclassify it. You can do it in mapserver at a significant 
cost to performance or you can do it with GDAL or other tools once so 
mapserver does not have to fiddle with every pixel.

In theory, there is no reason that mapserver couldn't do what you want, 
but it has to be coded and there are a bunch of cases would have to be 
resolved from a use case point of view, like how to deal with other 
other kinds of rasters with multiple bands, etc.

-Steve W

On 3/5/2013 3:18 PM, Bistrais, Bob wrote:
> Yes, I had looked at that webpage and thought I was doing it correctly.
> My TIFF is a single band, 8-bit, with no colormap.  Still don’t see why
> it won’t display in color.
>
> *From:*Brent Fraser [mailto:bfraser at geoanalytic.com]
> *Sent:* Tuesday, March 05, 2013 3:13 PM
> *To:* Bistrais, Bob
> *Cc:* mapserver-users at lists.osgeo.org
> *Subject:* Re: [mapserver-users] Trouble coloring a raster
>
> Bob,
>      I'd recommend just re-rendering the raster off-line for performance
> reasons, but if data management makes that difficult have a look at the
> "Classifying Rasters" section of
> http://www.mapserver.org/input/raster.html#how-are-rasters-added-to-a-map-file.
> And Mapserver can only classify a single 8-bit  band (grey or paletted),
> even if your image is say 3 band RGB.
>
> Best Regards,
>
> Brent Fraser
>
> On 3/5/2013 12:53 PM, Bistrais, Bob wrote:
>
>     I have a geotiff raster which represents forested lands.  I’d like
>     it to display in green.  I put in a Style section and specified a
>     color, but try as I might, it always displays in grayscale.  It is
>     an 8-bit unsigned TIFF file.
>
>     Below is the layer specification:
>
>     LAYER
>
>        NAME "ForestLands"
>
>        GROUP "ForestLands"
>
>        TYPE RASTER
>
>        STATUS on
>
>        DATA "/mapserver_data/StreamBarriers/forestland06.tif"
>
>        METADATA
>
>          "wms_srs"                      "EPSG:4326 EPSG:26919 EPSG:26983
>     EPSG:26984 EPSG:102113"
>
>          "wms_name"                                "ForestLands"
>
>          "wms_server_version" "1.1.1"
>
>          "wms_format"              "image/png"
>
>        END
>
>        CLASS
>
>          NAME "Forest"
>
>          STYLE
>
>              COLOR 0 250 0
>
>          END
>
>        END
>
>     END
>
>
>
>
>     _______________________________________________
>
>     mapserver-users mailing list
>
>     mapserver-users at lists.osgeo.org  <mailto:mapserver-users at lists.osgeo.org>
>
>     http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
>
> _______________________________________________
> 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