#SETUP
import pyqtree
spindex = pyqtree.Index(bbox=[0,0,1000,500])
#ADD SOME ITEMS
for item in items:
spindex.insert(item=item, bbox=item.bbox)
#RETRIEVE ITEMS FROM A REGION
result = spindex.intersect(bbox=[233,121,356,242])
Just for whatever it's worth, scipy.spatial.KDTree (and/or scipy.spatial.cKDTree, which is written in C for performance reasons) is a far more robust choice than the options listed.
python包索引在搜索四叉树时生成另外两个库:http://pypi.python.org/pypi?%3Aaction=search&term=quadtree&submit=search
免责声明:从未使用过四叉树或任何这些库。
另一个要检查的库是PyQuadTree,这是一个纯python四叉树索引,也可以在python 3x上工作。您只需要添加一个项作为4长度序列的边界框,这样它就可以用于各种用途,甚至负坐标系。
虽然我是作者,但我实际上只是采用了其他人的四叉树结构/代码,使其更加用户友好,添加了对矩形四叉树的支持,并添加了文档。如何使用它的一个简单示例:
在this comment中,joferkington引用当前问题并说:
相关问题 更多 >
编程相关推荐