-1

我有一个 rtree,其中包含点,即 left == right && top == bottom:

...
idx = index.Index()
....
*print list(idx.nearest((rand_point[0], rand_point[1], rand_point[0], rand_point[1])))
...
left, bottom, right, top = (newpoint[0], newpoint[1], newpoint[0], newpoint[1])
idx.insert(i, (left, bottom, right, top))
...

代替点的是一些长代码,它定义了“point”、“newpoint”、“i”以及循环中的所有内容。标有 * 的行返回类似:

[0L]
[0L]
[2L]
[2L]
[1L]
[4L]
[6L]
[5L].....

问题是如何得到一个点,即(左、下、右、上)知道这个输出?

4

2 回答 2

0

利用

idx.nearest(.... objects="raw")

或者

idx.nearest(.... objects=True)

如果您想要实际的对象,而不仅仅是 ID。

于 2014-04-29T22:50:44.917 回答
0

我找到了解决方案:

    nearest_gen = idx.nearest((rand[0], rand[1], rand[0], rand[1]), objects=True)
    nearest_list = list(idx.nearest((rand[0], rand[1], rand[0], rand[1])))
    for j in nearest_gen:
        if j.id == nearest_list[0]:
            j.object
            print ['%.10f' % t for t in j.bbox]
于 2014-05-05T08:56:38.373 回答