Friday, 27 July 2018

Cut a polygon with two lines in shapely

I am trying to cut a shapely.geometry.Polygon instance into two parts with two lines. For example, in the code below, polygon is a ring and if we cut it with line1 and line2 we should get two partial rings, one w/ 270 degrees and one with 90 degrees. Would there be a clean way to do this?

Thank you!

Shawn

from shapely.geometry import Point, LineString, Polygon

polygon = Point(0, 0).buffer(2).difference(Point(0, 0).buffer(1))
line1 = LineString([(0, 0), (3, 3)])
line2 = LineString([(0, 0), (3, -3)])



from Cut a polygon with two lines in shapely

No comments:

Post a Comment