Algorithm to find if location (latitude , longitude) is within radius range of a given location (latitude, longitude) [closed]

StackOverflow https://stackoverflow.com/questions/19896904

Question

I am given a file with interesting locations in some cities in the united states.

in another file, I am given a lot of data for train/taxi pickups. I would like to know of an easy to implement algorithm to find if one of these pickup locations is within some x kilometers / miles from one of the interesting locations.

I am writing a python script to do that.

EDIT I would like to know if I can import a library which has a function that I can use.

Was it helpful?

Solution

There is a python library called haversine that does this calculation.

OTHER TIPS

You might want to look into spatial data structures like the k-d tree or quadtree, which are optimized to answer queries of the form "what points are close to some test point p?" There are lots of good references for and implementations of these data structures online, and you might be able to use some of them to solve your problem simply and efficiently.

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top