Example #1
0
p.set_leaf_capacity(10)

def get_points(filename):
    for id, l in enumerate(open(filename)):
        x,y = l.split()
        x,y = float(x), float(y)
        yield (id, (x,y,x,y), None)
        

idx1 = Rtree(get_points(sys.argv[1]), properties=p)
idx2 = Rtree(get_points(sys.argv[2]), properties=p)

idx1.select_mbrs(40);
idx2.select_mbrs(40);

print idx1.hausdorff(idx2,1)
print idx2.hausdorff(idx1,1)
print idx1.hausdorff(idx2,2)
print idx2.hausdorff(idx1,2)
print idx1.hausdorff(idx2,0)
print idx2.hausdorff(idx1,0)
print

idx1.select_mbrs(80);
idx2.select_mbrs(80);

print idx1.hausdorff(idx2,1)
print idx2.hausdorff(idx1,1)
print idx1.hausdorff(idx2,2)
print idx2.hausdorff(idx1,2)
print idx1.hausdorff(idx2,0)
Example #2
0
from rtree import Rtree

idx = Rtree()
idx.add(5, (1,2,1,2))
idx.add(1, (2,0,2,0))
idx.add(2, (3,0,3,0))
idx.add(3, (4,0,4,0))
idx.add(4, (5,0,5,0))
idx2 = Rtree()
idx2.add(10, (0,0,0,0))
idx2.add(11, (1,1,1,1))

print 'Dimensions: %d' % (idx.properties.dimension,)
h = idx.hausdorff(idx2)
id1 = h[1].contents.value
id2 = h[2].contents.value
print 'Hausdorff distance: %.2f, %d, %d' % (h[0], id1, id2)