|


Formula for Radial Latitudes and LongitudesDate: 10/15/2002 at 00:28:44 From: Bill Tait Subject: Formula for radial latitudes and longitudes I have a database of places that lists a latitude and longitude for each place. I want to make a radius search tool that returns all places based on latitude/longitude within a certain radius (say 5 miles) of a given place. I have already created one that will return results of a square or rectangle, but I can't figure out how to do this when it's a radius. Obviously calculating the area is easy, but to display a list of every lat/lon within that area is the problem. Any ideas? Regards, Bill Tait Date: 10/15/2002 at 08:31:37 From: Doctor Rick Subject: Re: Formula for radial latitudes and longitudes Hi, Bill. We get lots of questions like this. Here's what you need to do. For each point in your database, compute the distance between that point and the given point. If it's less than the specified distance, add it to your list of places within the circle. I suggest the following algorithm for calculating distance: Haversine Formula http://mathforum.org/library/drmath/view/51879.html If you're only considering short distances like 5 miles, you can use an approximation for short distances in which the earth can be regarded as flat. It's explained here: Circle of Radius 1 km around Given Latitude/Longitude http://mathforum.org/library/drmath/view/61135.html Using this method, you will convert the longitude (a2) and latitude (b2) of each point, with a1 and b1 equal to the longitude and latitude of the given point, to x and y, then calculate r^2 = x^2 + y^2 If this is less than the given distance squared, add the point to the list. This approximation requires fewer trig functions, but it still requires one. It only needs to be computed once for the given point, however, not for each point in the database. - Doctor Rick, The Math Forum http://mathforum.org/dr.math/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]


Ask Dr. MathTM
© 1994-2013 The Math Forum
http://mathforum.org/dr.math/