I came across the same issue and there doesn't seem to be a generic solution. So here is my hack around, hopefully can be of help:
My set up:
class Point:
def __init__(self,x,y):
self.x = x
self.y = y
When I index all my points, I run this code:
idx = index.Index()
# input_points is a list of Point object
for ind, pt in enumerate(input_points):
idx.insert(ind, (pt.x, pt.y, pt.x, pt.y))
return idx
Here you may have noticed that the id
I assigned to each point is the index of that point inside my input_points
list.
So later when I want to get a specific point by id, I run:
target_point = input_points[id]
Then you can do things with the target_point because that should be the point you are looking for.
This is ONLY a hack around, so please let me know if you found a generic solution, I am curious too.