Calculate radius from coordinates and find all matches within the radius in a table
10,592
You need to familiarize yourself with the Haversine forumla This will calculate the distances from lat and lon as you expected through mysql
Comments
-
Ben Fransen almost 2 years
Possible Duplicate:
SQL: Determine if one coordinate is in radius of anotherIn a table I have stored latitude and longitude (as floats). Now I want to query my table to find all rows which have coordinates within a given radius (which can ben 2km, 5km, 10km etc. etc.). I really don't have a clue how to achieve this so any help will be greatly appreciated. I'm not sure how query, because I think the result will be an endless set of coordinates representing the 'border' of the radius where I somehow have to tell my table to search for results within that 'border'.
-
Ben Fransen over 11 yearsThanks for your answer, +1. I'm going to try Shubhansh solution first, if that won't work I'll give your suggestion a try.