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

Stephen Lime steve.lime at dnr.state.mn.us
Tue Aug 7 10:52:12 EDT 2001


Just to clarify, the syntax below is kinda wrong. Regex is best for strings not
ranges, use logical expressions, eg.

CLASS
  COLOR 43 196 0
  EXPRESSION ([POP] >= 0 AND [POP] < 10000)
END

CLASS
  COLOR 43 196 255
  EXPRESSION ([POP] >= 10000)
END

Of course there are other options depend on exactly what is in the population 
column (i.e. actual population totals vs a population class).

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> Puneet Kishor <pkishor at GeoAnalytics.com> 08/07/01 08:36AM >>>

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