python shapely buffer analysis and display

Refer to Zhihu's buffer article

And a foreign link https://deparkes.co.uk/2015/03/11/how-to-plot-polygons-in-python/

1. Introduce shapely

from shapely.geometry import Point, Polygon, LineString

2. Point, line buffer

point

# 定义点
point_1 = Point(1, 1)
# 两个点以指定的缓冲距离为半径生成圆形区域
a = point_1.buffer(2)

line

# 定义线段
line = LineString([(0.1, 0.1), (2, 3)])
# 生成缓冲区
buffer = line.buffer(0.5)

3. Hand in and display

Intersection of line and buffer:

intersect=line.intersection(a)

display:

x1,y1=line.xy

x2,y2=buffer.boundary.xy

plt.figure()

plt.plot(x1,y1)

plt.plot(x2,y2)

plt.show()

show result:

Guess you like

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