[mapserver-users] Re: Mapserver + NDVI styling

Jorge Arévalo jorge.arevalo at deimos-space.com
Thu Sep 29 03:49:34 PDT 2011


Thanks for the response. Now, I'm sure I must generate the legend
based on the classification specified in the mapfile or generate it by
myself and manually include it in a template. Good to know it.

2011/9/29 Steve Lime <sdlime at gmail.com>:
> Unfortunately MapServer isn't bright enough to generate a legend
> solely from an image itself. The legend code
> just wasn't built for such a task.Sorry... Steve
>
> 2011/9/28 Jorge Arévalo <jorge.arevalo at deimos-space.com>:
>> 2011/9/28 Jorge Arévalo <jorge.arevalo at deimos-space.com>:
>>> I'm serving a NDVI coverage via Mapserver. So, one band, float32
>>> values, [-1.0, 1.0]. I want to display the NDVI in greyscale, and
>>> generate a legend. I've tried 2 things:
>>>
>>> - Create two dummy classes, just for testing:
>>>
>>> CLASS
>>>    NAME "rojo"
>>>    EXPRESSION ([pixel] < 0.3)
>>>    STYLE
>>>        COLOR 255 0 0
>>>    END
>>> END
>>>
>>> CLASS
>>>    NAME "azul"
>>>    EXPRESSION ([pixel] >= 0.3)
>>>    STYLE
>>>        COLOR 0 0 255
>>>    END
>>> END
>>>
>>> So, my legend looks like this: http://dl.dropbox.com/u/6599273/leyenda.png
>>>
>>> And the image, obviously, is red and blue:
>>> http://dl.dropbox.com/u/6599273/capturas/ndvi_en_gvsig.png
>>>
>>> But I'd like to see the image in greyscale... The I've tried the next thing
>>>
>>> - Pre-classify values with PROCESSING "SCALE=-1.0, 1.0". I don't know
>>> what Mapserver internally does with this processing order, but I can
>>> see the image in greyscale:
>>> http://dl.dropbox.com/u/6599273/capturas/ndvi_gris_en_gvsig.png
>>>
>>> The problem is now I can't see any legend, because I've not created
>>> any class. I'd like to see all the different levels of the grayscale
>>> image in my legend.
>>>
>>> How could I do it?
>>>
>>> Many thanks in advance
>>>
>>> --
>>> Jorge Arévalo
>>> Internet & Mobility Division, DEIMOS
>>> jorge.arevalo at deimos-space.com
>>> http://es.linkedin.com/in/jorgearevalo80
>>> http://mobility.grupodeimos.com/
>>> http://gis4free.wordpress.com
>>> http://geohash.org/ezjqgrgzz0g
>>>
>>
>> Ok, I've found a way, but I'm sure it isn't the shortest path.
>>
>> Basically, I've generated a legend using GRASS (r.colors to add grey
>> color as color interpretation for band and d.legend to generate the
>> legend). The legend is generated from the ndvi file. So, I guess I can
>> create a HTML template as Mapserver legend, using the legend generated
>> by grass (here:
>> http://dl.dropbox.com/u/6599273/grass/grass_legend.png)
>>
>> On the other hand, I know how to generate a legend in Mapserver using
>> CLASS objects in the mapfile, but I don't know how to generate that
>> legend without the CLASS options in the mapfile.
>>
>> Am I taking the long way on this? Is there an easier way to generate a
>> legend for a NDVI file in Mapserver?
>>
>> Many thanks in advance
>>
>> --
>> Jorge Arévalo
>> Internet & Mobility Division, DEIMOS
>> jorge.arevalo at deimos-space.com
>> http://es.linkedin.com/in/jorgearevalo80
>> http://mobility.grupodeimos.com/
>> http://gis4free.wordpress.com
>> http://geohash.org/ezjqgrgzz0g
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>



-- 
Jorge Arévalo
Internet & Mobility Division, DEIMOS
jorge.arevalo at deimos-space.com
http://es.linkedin.com/in/jorgearevalo80
http://mobility.grupodeimos.com/
http://gis4free.wordpress.com
http://geohash.org/ezjqgrgzz0g



More information about the MapServer-users mailing list