0

In python, given S, a dataset (of 2D points) and T a subset of it. I find the nearest neighbours of T in S with cKDTree:

tree = cKDTree(S)
distances, indices = tree.query(T,2)

Now, my dataset is growing with time, so say I have accumulated an extra dataset S2 and I need to know the nearest neighbours of T2 (subset of S2) in the entire dataset, which is now the union of S & S2.

I'm searching for a way to update 'tree' for S2 rather than recomputing it on the entire dataset everytime again. Alternatively, computing a tree on S2 and merging the trees would do the trick as well I suppose...

NB: in my case, usually T2 has just 1 point, whereas S & S2 are rather large (hundreds to hundred thousands).

Oath
  • 67
  • 4
  • 1
    Check out [this answer](https://stackoverflow.com/a/17822258/3670871). It looks like KD trees are not really made for modification, so you may end up needing to regenerate. Or do something clever and new! – Engineero Nov 02 '17 at 15:13
  • Possible duplicate of [Is there any way to add points to KD tree implementation in Scipy](https://stackoverflow.com/questions/17817889/is-there-any-way-to-add-points-to-kd-tree-implementation-in-scipy) – crypdick Jul 13 '18 at 21:17

0 Answers0