Juan Pablo Caram
2014-12-27 21:23:20 UTC
Hi,
I'm having trouble deleting from an rtree index. In the script below I add
3 points and then try to delete them:
from rtree import index as rtindex
pts = [[0.0, 0.0], [0.0, 1.0], [1.0, 1.0]]
rt = rtindex.Index()
print rt.interleaved
[rt.add(0, [x[0], x[1], x[0], x[1]]) for x in pts]
print [x.bbox for x in list(rt.nearest([0, 0], 10, True))]
for x in pts:
rt.delete(0, [x[0], x[1], x[0], x[1]])
print x, [x.bbox for x in list(rt.nearest([0, 0], 10, True))]
And the result is:
True
[[0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0]]
[0.0, 0.0] [[0.0, 1.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0]]
[0.0, 1.0] [[0.0, 1.0, 0.0, 1.0]]
[1.0, 1.0] [[0.0, 1.0, 0.0, 1.0]]
Basically, when trying to delete [0, 1] it's deleting the wrong thing. Is
this a bug or am I using it wrong?
Thanks,
JP
I'm having trouble deleting from an rtree index. In the script below I add
3 points and then try to delete them:
from rtree import index as rtindex
pts = [[0.0, 0.0], [0.0, 1.0], [1.0, 1.0]]
rt = rtindex.Index()
print rt.interleaved
[rt.add(0, [x[0], x[1], x[0], x[1]]) for x in pts]
print [x.bbox for x in list(rt.nearest([0, 0], 10, True))]
for x in pts:
rt.delete(0, [x[0], x[1], x[0], x[1]])
print x, [x.bbox for x in list(rt.nearest([0, 0], 10, True))]
And the result is:
True
[[0.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0]]
[0.0, 0.0] [[0.0, 1.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0]]
[0.0, 1.0] [[0.0, 1.0, 0.0, 1.0]]
[1.0, 1.0] [[0.0, 1.0, 0.0, 1.0]]
Basically, when trying to delete [0, 1] it's deleting the wrong thing. Is
this a bug or am I using it wrong?
Thanks,
JP