python shapely 緩衝區分析和顯示

參考知乎的緩衝區文章

和一個國外的鏈接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()

顯示結果:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章