I would like to save an Rtree spatial index to file. I tried using pickle.dump, but when I loaded the .p file using pickle.load, the bounds were way off. Here's an example:
import rtree, pickle
from rtree import index
iidx=index.Index()
iidx.add(0,(1,2,3,4))
f=open('rtree2.p','wb')
pickle.dump(iidx,f)
f.close()
When I try opening the file:
f=open('rtree2.p','rb')
uudx=pickle.load(f)
f.close()
uudx.get_bounds()
I get:
[1.7976931348623157e+308, 1.7976931348623157e+308, -1.7976931348623157e+308, -1.7976931348623157e+308]
insert
method, and reloaded it, but the new index has just one index node with all the leaves in that.