Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the nearest neighbors for latitude and longitude point on python?

Input:

point = (lat, long)
places = [(lat1, long1), (lat2, long2), ..., (latN, longN)]
count = L

Output: neighbors = subset of places close to the point. (len(neighbors)=L)

Question: Can I use kd-tree for quick nearest-neighbors lookup for points with latitude and longitude? (For example, implementation in scipy)

Is it necessary to transform the geographical coordinates (latitude and longitude) of the point in the coordinates x,y?

Is it the best way to solve this?

like image 417
Andrei Avatar asked May 19 '16 13:05

Andrei


1 Answers

scikit-learn provides a BallTree class that supports the Haversine metric. See also this SO question.

like image 64
Florian Brucker Avatar answered Sep 22 '22 13:09

Florian Brucker