3

Given a database of GPS points, a center GPS location, and a radius R (in meters), how can I find all points in the database that are within a distance of R of the center point? Will the distance iso-lines be an ellipse?

6
  • 2
    By definition, distance isolines are circles. In the sense that all circles are special cases of ellipses, the answer to your last question is "yes." More significantly, these isolines may appear as ellipses (or even more distorted shapes) when drawn on a map, depending on the projection and the magnitudes of the distances. For smallish distances (often 1000 km or less), the isolines will be extremely close to circular on any map using a conformal projection.
    – whuber
    Commented Feb 29, 2012 at 16:48
  • 1
    Please consider indicating (by means of a tag or within the question itself or both) what software you intend to use.
    – whuber
    Commented Feb 29, 2012 at 16:49
  • 2
    @whuber the queries would be over small distances (likely in the range: 10m - 10km). I'm implementing my own software, so I'd like to understand the specific equations I'd need in order to compute distances and convert distances in 'meters' (from a given location) back into GPS coordinates.
    – Nick
    Commented Feb 29, 2012 at 16:56
  • 1
    Nick, how accurate do the formulas need to be and in what coordinates are the GPS points recorded? How many points are involved? What database is being used? Unless you have unusual needs, it is possible your question is already answered on this site. A search on distance and formula might do the trick.
    – whuber
    Commented Feb 29, 2012 at 17:03
  • 1
    Nick, The fist step for this problem is to perform the conversion (projection) between coordinate systems (lat/lon <-> m). Are you sure that you want to implement that yourself? There are good libraries available that do that for you and the distance calculation also, see OGR/GDAL.
    – Pablo
    Commented Feb 29, 2012 at 18:46

3 Answers 3

5

For such short distances and since you are doing the coding yourself, the flat earth equations would probably be a good enough approximation but it depends on your accuracy requirements.

Compute the distance from latp,lonp to lat1/lon1 via the equirectangular projection:

p1 = (lonp - lon1) cos ( 0.5*(latp+lat1) ) //convert lat/lon to radians
p2 = (latp - lat1)
distance = EarthRadius * sqrt( p1*p1 + p2*p2)
use EarthRadius = 6371000 meters and your distance will be in meters

Latp/Lonp will be your reference lat/lon (in radians!). Lat1/Lon1 will be the point you are testing. Once you have distance, it is an easy test to determine if the point lies within your circle.

Reference: section Equirectangular approximation at the site: http://www.movable-type.co.uk/scripts/latlong.html

1
  • What if we also have elevation (or z)?
    – mavavilj
    Commented Jan 7, 2020 at 11:47
5

Vincenty's formulae devised by Thaddeus Vincenty is also worth it.

You can head to the page entitled Vincenty formula for distance between two Latitude/Longitude points.

Other implementations:

4

For a spherical earth I have found that the formulas in the Aviation Formulary. For the distances you are working these distance calculations are more than adequate.

Unless of course your GIS package includes these calculations, or tools to select by buffering and intersecting.

1
  • @Nick precisely
    – Shiko
    Commented Nov 29, 2016 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.