from shapely.geometry import MultiPolygon, Polygon, LineString
多边形
square=Polygon(((4, 4), (50, 4), (50, 61), (4, 60)))
square
有孔洞多边形
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
线
line = LineString([(2, 22), (50, 50)])
线与面相交
line.intersection(square_with_hole)
多边形边界
square_with_hole.boundary
线与多边形边界相交
line.intersection(square_with_hole.boundary)