3

I need to color polygons in different colors, ensuring that polygons sharing boundaries do not have the same color (the well-known four color theorem).

Is there a way to do that using GeoTools?

5

1 Answer 1

2

I have an implementation that will colour most (some?) simpler maps with 5 colours, it turns out 4 colours is a very hard algorithm to understand so I skipped that and went with the simpler 5 colours. I also only implemented Rule 1 rather than the more complex rule 2 so it can only handle maps where there are polygons with fewer than 5 neighbours. This is true for all the polygon sets I've tested on, but your mileage may vary.

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.