6

I have several polygon layers and I want to set 4 colors to fill all of those, but the color of one layer should not be the same with the adjacent polygon.

I have read several questions about randomizing colors or using color ramps but most appear to be reliant on attribute fields/columns. It would be very tedious to make another style column in the attribute table, and in my case, it would be impractical because I want the colors to automatically adjust so that they are distinct from each neighboring polygon.

Is there a way to do this?

2 Answers 2

2

There is a theorem that proves that it is possible to create such a map in all cases, but this can only be achieved by "raw force" and requires to compute the adjacency of all polygons, which is computationnally expensive. Furthermore, you need to recompute the colors for the whole map when you merge/split one polygon, because a local change affect its surrounding, but every change will propagate so that your first color change could become invalid. I am afraid that you have no "on the fly" solution except adding a fifth/sixth color for fast rendering (this is not a technical issue).

You therefore need work with a additionnal column (or in memory table) where you store the color codes, so the solutions on this site will be valid for your.

E.g. Topocolor plugin : four color theorem for QGIS 2.0 or Leaflet?

2
0

Use the Welsh Powell Graph colouring Algorithm

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.