v.greedycolors works best if areas have unique categories. If multiple areas have the same category, the corresponding network of neighboring areas can become fairly complex, resulting in a larger number of greedy colors. If the purpose is to assign different colors to neighboring areas, irrespective of their category values, unique category values need to be assigned first, e.g. to a new layer with v.category.
There is always at least one optimal solution for greedy colors, using as few colors as possible. However, it is usually computationally intensive and not practical to search for an optimal solution. Therefore a good solution is aproximated by ordering the areas first, before assigning greedy colors. Here, the areas with the least neighbors are processed first.
Make a copy of the data:
db.select sql="select greedyclr,count(greedyclr) from my_boundary_county group by greedyclr"
greedyclr|count(greedyclr) 1|262 2|351 3|302 4|11
Assign RGB colors:
v.db.addcolumn map=my_boundary_county column="GRASSRGB varchar(11)" v.db.update map=my_boundary_county column=GRASSRGB value="127:201:127" where="greedyclr = 1" v.db.update map=my_boundary_county column=GRASSRGB value="190:174:212" where="greedyclr = 2" v.db.update map=my_boundary_county column=GRASSRGB value="253:192:134" where="greedyclr = 3" v.db.update map=my_boundary_county column=GRASSRGB value="255:255:153" where="greedyclr = 4"
Latest change: Monday Jan 30 19:52:26 2023 in commit: cac8d9d848299297977d1315b7e90cc3f7698730
© 2003-2023 GRASS Development Team, GRASS GIS 8.3.1dev Reference Manual