python shapely polygon and intersection representation

from shapely.geometry import MultiPolygon, Polygon, LineString

Polygon

square=Polygon(((4, 4), (50, 4), (50, 61), (4, 60)))
square

Insert picture description here

Polygon with holes

square_with_hole = Polygon([(4, 4), (50, 4), (50, 61), (4, 61)], [[(5, 10), (8, 40), (14, 30.02)],[(13, 6), (15, 8), (19, 9)]])
square_with_hole

Insert picture description here

line

line = LineString([(2, 22), (50, 50)])

Insert picture description here

Intersect line and face

line.intersection(square_with_hole)

Insert picture description here

Polygon boundary

square_with_hole.boundary

Insert picture description here

Line intersects with polygon boundary

line.intersection(square_with_hole.boundary)

Insert picture description here

Guess you like

Origin blog.csdn.net/lebusini/article/details/109843295