Python 使用morton代码查找最近的邻居
我已经实现了一种Python 使用morton代码查找最近的邻居,python,nearest-neighbor,z-order-curve,Python,Nearest Neighbor,Z Order Curve,我已经实现了一种解码/编码方法,用于将2d点转换为各自的莫顿码 我要找的是找到最近的邻居(在最小距离下) 举个例子: points=[(200,300),(500,150),(100,50)] mortonCodes = {} for p in points: mortonCodes[encode(p)] = p nearest = findNearestNeighbor(mortonCodes, (201,305)) print(nearest) # ---> should r
解码/编码
方法,用于将2d点转换为各自的莫顿码
我要找的是找到最近的邻居(在最小距离下
)
举个例子:
points=[(200,300),(500,150),(100,50)]
mortonCodes = {}
for p in points:
mortonCodes[encode(p)] = p
nearest = findNearestNeighbor(mortonCodes, (201,305))
print(nearest) # ---> should return (200,300)
这可能吗 您可以使用
minu distance
执行以下操作,例如120:
使用查询点qp=(201305)
并通过减去/添加距离来创建最小点和最大点:min=(81185)
和max=(321425)
。
现在,为这两点创建morton代码
所有距离(210305)120以内的点都将有一个莫顿代码
mcWithin120
withmortonCode(min)是的,你是对的,我会投票,因为我不知道PH树,我认为这将是更好的解决方案!还可以看看这一点,特别是在使用morton order进行kNN搜索时引用PDF的注释。