Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This is probably a long shot, but is there a way to automatically select colours for neighbouring regions using the four colour theorem, in PostGIS? The data I'm using is suburb boundaries in OpenStreetMap (boundary=administrative, admin_level=10).

share|improve this question
add comment

1 Answer

I had a similar question from an Esri customer once. The answer was to create a field of a numerical type, which could hold a value from 1-4. The colour was then set from the attribute of that field. The issue was to get the values. We created a script that took the first polygon in a dataset gave it the number one, then took the next polygon. If it touched the first then it got a 2, if it didn't it became a 1. Then you iterate through each one checking to see what other values are touching it, always defaulting to the lowest number. In the end I had to use a number 5, but very occassionally - it got to the point where writing the code was exceeding the value of getting to 4.

Depends how many polygons, you've got, but if not many then you could do it manually?

share|improve this answer
    
Thanks - I missed this response for some reason. This approach seems reasonable, and highlights a dumb assumption I made - using slightly more than 4 colours would actually be fine :) Wonder if I can find a script to do this in PostGIS. –  Steve Bennett Aug 6 '13 at 5:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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