和一個國外的鏈接https://deparkes.co.uk/2015/03/11/how-to-plot-polygons-in-python/
1.引入shapely
from shapely.geometry import Point, Polygon, LineString
2.點,線的緩衝區
點
# 定義點
point_1 = Point(1, 1)
# 兩個點以指定的緩衝距離爲半徑生成圓形區域
a = point_1.buffer(2)
線
# 定義線段
line = LineString([(0.1, 0.1), (2, 3)])
# 生成緩衝區
buffer = line.buffer(0.5)
3.交併顯示
線與緩衝區的交:
intersect=line.intersection(a)
顯示:
x1,y1=line.xy
x2,y2=buffer.boundary.xy
plt.figure()
plt.plot(y1,x1)
plt.plot(x2,y2)
plt.show()
顯示結果: