4

Currently have a working example using scipy.spatial.KDTree to do a nearest neighbour look up for some x,y points.

Question is, if I have datetime data for each x,y point can I put that into a KDTree and modify my spatial nearest neighbour search to do a nearest spatio-temporal neighbour search?

Searching for nearest spatial neighbours with:

pts = np.array([[1, 50], [1.89, 52.4]])

print tree.query(pts, k=5)

Community
  • 1
  • 1
user965586
  • 563
  • 5
  • 22
  • I think this thread can help answer your question: [http://stackoverflow.com/questions/788005/is-a-kd-tree-suitable-for-4d-space-time-data-x-y-z-time](http://stackoverflow.com/questions/788005/is-a-kd-tree-suitable-for-4d-space-time-data-x-y-z-time) Also what about just using the datetime property to filter your point before building the tree? – bcollins Aug 09 '13 at 01:41
  • Thanks for that, its clarified a few things. Could you expand on your last line please? Suppose you want to return points in a SPATIAL distance and within a TIME period. Would a KD-Tree be able to do this? Using 'KDTree.query' you can say give me the closest n points, but what if you want to specify that time range too? The spatial search can be done by 'KDTree.query_ball_point' or similar. – user965586 Aug 09 '13 at 10:45

0 Answers0