Fun with shapely
instersections...
#500
villares
started this conversation in
Show and tell
Replies: 2 comments 15 replies
-
This is great! Thanks for sharing this. I like the use of |
Beta Was this translation helpful? Give feedback.
11 replies
-
Probably faster, but but also more readable! @lru_cache(maxsize=64)
def get_regions(polys):
global regions # for debugging
regions = []
n = len(polys)
for i in range(1, n + 1):
for combo in combinations(range(n), i):
intersection = intersection_all([polys[j] for j in combo])
not_in_combo = unary_union([polys[k] for k in range(n) if k not in combo])
regions.append(intersection.difference(not_in_combo))
return GeometryCollection(regions).buffer(-3) The only thing is now the resulting polygons order (and thus coloring on the example) is less stable, changing at each small move. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Beta Was this translation helpful? Give feedback.
All reactions