[mapserver-users] How to color a polygon depending on one of its DBF attribute ?

Puneet Kishor pkishor at GeoAnalytics.com
Tue Aug 7 06:36:42 PDT 2001


On Tuesday, August 7, 2001, at 01:16  AM, Speh Sylvain wrote:

> Hi list,
>
> Whichever is the map I'm looking at, they are all made on the same 
> pattern :
> one class --> one color.
> I wonder how to get a layer whose polygons are filled with the color of 
> an
> attribute or from a computed expression.
> Imagine there is a population layer ( 100 citizens for the less populous
> polygon , 10,000 for the more ).
>
> How can I color them like
> COLOR 43 196 x
> with x = 0 for 100 and x = 255 for 10,000, or else ( like/dark 
> polygon ) ?
>
>

Well, you will still have one class --> one color. However, no one is 
stopping you from breaking the layer into multiple classes. So, you have 
a pop layer, and you have classes like so (check the correct syntax)...

classitem pop
class name 0-100
expression /0-100/     # check the syntax for reg exps, or use sql kinda 
syntax
color firstcolor

class name 100-199
expression /100-199/
color secondcolor

class name 200-299
expression /200-299/
color thirdcolor

you get the gist.


as a bonus, if you are drawing the legend, you will also get a nicely 
formatted, labeled legend.

have fun,

pk/



More information about the MapServer-users mailing list