【发布时间】:2015-06-14 21:00:19
【问题描述】:
我有一个数据列表如下:
from shapely.geometry import box
data = [box(1,2,3,4), box(4,5,6,7), box(1,2,3,4)]
sublists = [A,B,C]
列表“数据”有以下子列表:
A = box(1,2,3,4)
B = box(4,5,6,7)
C = box(1,2,3,4)
我必须检查子列表是否相交。如果相交,它们应该放在一个元组中;如果不相交,则应放入不同的元组。预期结果是:
result = [(A,C), (B)]
怎么做?
我试了一下:
results = []
for p,c in zip(data,sub_lists):
for x in data:
if p.intersects(x): ##.intersects return true if they overlap else false
results.append(c)
print results
【问题讨论】:
-
对于我们这些没有使用过
shapely的人来说,box()返回的对象可以做什么?这是一个关于比较/迭代 Python 列表的问题,还是关于使用shapely的问题。 'numpy' 是如何进入方程的? -
@hpaulj 关于 python 列表。但 shapely 用于测试相交。 box() 返回匀称的多边形。
标签: python python-2.7 python-3.x numpy shapely