[python][原创]判断2个多边形是不是重叠

代码适合矩形或者多边形是不是和另一个多边形有重叠

from shapely.geometry import Point, LineString
from shapely.geometry import Polygon,MultiPoint  #多边形
import matplotlib.pyplot as plt
point = Point(4, 4)
poly1 =Polygon([(0, 0), (1,1),(2, 0), (2, 2), (0, 2)])
poly = Polygon([(0, 0), (2,2),(3, 0), (3, 3), (0, 3)])
print(poly.area)
print(poly.intersects(poly1))
ax = plt.gca()                                 #获取到当前坐标轴信息
ax.xaxis.set_ticks_position('top')   #将X坐标轴移到上面
ax.invert_yaxis()                            #反转Y坐标轴
plt.plot(*poly.exterior.xy)
plt.plot(*poly1.exterior.xy)
plt.show()

你可能感兴趣的:(Python,python,几何学,开发语言)