Solved

Proportional class assignment with adjacency constraints


Badge +22
  • Contributor
  • 1961 replies

I have a scenario where polygons need to be "randomly" assigned to one of N classes such that no intersecting polygons share the same class and that there are roughly the same number of polygons in each class.

 

 

My initial thought was to use the FeatureColorSetter (Map coloring) to ensure no adjacent features had the same color, and then randomize within each color group to get the total number of classes, but the color groups are in no way proportional. There is a distinct bias towards the lower color_ids.

 

 

If I just randomize the polygons then check for adjacency issues, and re-randomize the problems, I could end up in an infinite loop.

 

 

Thoughts on how to proceed?
icon

Best answer by takashi 11 May 2016, 12:34

View original

2 replies

Userlevel 2
Badge +17

Hi @jdh, it's an interesting challenge. I tried it with a SpatialRelator and PythonCaller. Please evaluate the attached workspace: collect-disjoint-polygons.fmw (FME 2016.1) [Updated]

Badge +22

Hi @jdh, it's an interesting challenge. I tried it with a SpatialRelator and PythonCaller. Please evaluate the attached workspace: collect-disjoint-polygons.fmw (FME 2016.1) [Updated]

That's very promising. Thank you.

Reply