Is it possible to randomly color polygons?
Stephen Woodbridge
woodbri at SWOODBRIDGE.COM
Thu Apr 12 17:10:36 PDT 2007
Jeff Hoffmann wrote:
> I have a layer with a lot of polygons that I want to display, but I
> don't really care about what color those polygons are (they're not
> classified, I'm not going to have a legend, I just want them to be
> different colors so no 2 adjacent polygons are the same color, e.g.
> counties in a state or states in the US). It seems like it'd be a
> pretty common thing to want, but is there a reasonably easy way to do
> it? I'm guessing the best way would be to assign a class to each of the
> polygons, but is there some sort of algorithm to figure out how many
> colors I need and how to assign them?
>
> Any ideas?
>
No, color randomly does not work, You need to apply the Four Color
theorem, see:
http://www.math.gatech.edu/~thomas/FC/fourcolor.html
Your best bet is to apply this to the polygons first and set an
attribute column dor a color number and then as you suggest use
mapserver class to select and render the color.
-Steve
More information about the MapServer-users
mailing list