'Shapely Difference on multiple MultiLineStrings
I have written a function blade that returns a Shapely MultiLineString. I would like to be able to run blade n-times, and have each subsequent call only be the difference of all the previous calls.
blade_list = []
for k in range(self.number_of_blades):
the_x = vsk.random(self.x_margin, vsk.width - self.x_margin)
the_length = vsk.random(self.min_length_of_blade, self.max_length_of_blade)
the_sway = vsk.random(self.min_sway_width, self.max_sway_width)
a_blade = blade(the_x, the_length, the_sway)
blade_list.append(a_blade)
def get_intersected(linesstring, multilinestrings):
inter_list = []
for mls in multilinestrings:
for ls in mls:
if ls.intersects(linesstring):
inter_list.append(ls)
return inter_list
occlude_list = []
for blades in blade_list:
for segments in blades:
inter_list = get_intersected(segments, blade_list)
for occluded_lines in inter_list:
occluded_lines = occluded_lines.difference(segments)
occlude_list.append(occluded_lines)
for ls in occlude_list:
vsk.geometry(ls)
I'm still teaching myself, so apologies in advance if this ends up being just a very silly problem, but I've been running into walls the last couple days trying to figure it out. Thanks in advance!
Solution 1:[1]
The answer was to make the function return both a multilinestring and a polygon.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Wyth |
