Hi,
Is there a way to divide records into equal parts based on the value of an attribute? In concrete terms, I want to divide 400 areas into 3 pieces, each of which is the same size.
Thx
Hi,
Is there a way to divide records into equal parts based on the value of an attribute? In concrete terms, I want to divide 400 areas into 3 pieces, each of which is the same size.
Thx
Best answer by geomancer
The approach provided above will always put considerably more 'weight’ in group 1 than in group 3.
It would be better to assign the sorted features consecutively to Group 1, Group 2, Group 3, Group 3, Group 2, Group 1, and so on.
After sorting, give each feature a number using @Count(). Then determine to which group to assign each feature, based on this number.
This can be done with a Conditional Value:
It is also possible (and much more fun 😀) to put these conditions in the Math Operator x?y:z (if condition x is true then use y, else use z):
@fmod(@int(@Value(Number)/3),2) == 0 ? @fmod(@Value(Number),3) : 2-@fmod(@Value(Number),3)
The attached workspace illustrates both approaches.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.