stefankoegl / kdtree

A Python implementation of a kd-tree
ISC License
365 stars 118 forks source link

actual distances #15

Closed vincefernando closed 10 years ago

vincefernando commented 10 years ago

Is it possible to get the minimum distance (squared) after search_nn without recalculating it?. For higher dimensional trees, distance recalculations could be expensive and should be avoided.

The same question for search_knn and search_nn_dist.

stefankoegl commented 10 years ago

Since 29e39c26428c578ed33623a3dd0ec88b889fec49 search_knn and search_nn return (node, dist) tuples instead of just nodes. I'll release this change as version 0.10 soon.

Sadabrata commented 4 years ago

Search_nn_dist seems to return the neighbouring points. However, in many cases, the distance of neighbours are also required. So after getting the nearest neighbours using search_nn_dist, I have to recompute their distance from the given point. It will be very good to have the distance of the neighbours returned along with the points. What I mean is tree.search_nn_dist(point, distance=5) to return (node, distance) just like search_knn

harish1996 commented 4 years ago

Search_nn_dist seems to return the neighbouring points. However, in many cases, the distance of neighbours are also required. So after getting the nearest neighbours using search_nn_dist, I have to recompute their distance from the given point. It will be very good to have the distance of the neighbours returned along with the points. What I mean is tree.search_nn_dist(point, distance=5) to return (node, distance) just like search_knn

I have sent a pull request implementing the same in #49. Check it out.