2

Does anyone know how to traverse the whole tree in this Python Rtree library?

I've checked all its methods but failed to find a interface for this.

Any help would be appreciated.

Jason Sundram
  • 12,225
  • 19
  • 71
  • 86
Brian Sun
  • 21
  • 1

2 Answers2

4

Do an intersection() query with the input parameters being those returned by bounds()? By definition everything in the index will intersect with a space equal to the bounds of the index.

Amber
  • 507,862
  • 82
  • 626
  • 550
0

I just tried to accomplish this, started to create a new thread for this and stackoverflow suggested me this thread instead.

For anyone stumbling across the same, I got ya.

Here is my working code.

import rtree
from random import random


rands =[random() for i in range(100)]

def generator_function():
    for i, coord in enumerate(rands):
        yield(i, (coord, coord+1, coord, coord+1), coord)

rtree = rtree.index.Index(generator_function())

for point in rtree.intersection(rtree.bounds):
    print(point)
Rack Cloud
  • 37
  • 5