I'm working on adding geofences to a mobile application. I know the proper way of calculating distance between two points on a sphere is using the great-circle or Haversine formula. I don't know if using those formulas are needed for relatively small scale applications. This leads to my question.

At what point does the distance given by a great-circle calculation diverge significantly from a planar calculation?

  • For the purposes of this discussion assume greater than 5% error is significant.

  • The geofence is simply a center point and a radius. If the point is within the radius, by distance, it is considered within the boundaries of the fence.

  • I am not sure if it matters, but I'm just worried about circular geofences at this time with a user defined radius between 50 and 200 meters.

marked as duplicate by whuber Mar 2 '16 at 16:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


whuber gave a wonderful answer that addresses the central folly of this idea. While he doesn't say this directly most people, like me, initially overlook two interrelated factors.

  1. Longitude converges at the poles. That means that the distance between 0o longitude and 1o longitude is different when measuring along the equator and the 80th parallel.

  2. Planar coordinate systems rely on a constant rate of change in both the x and y directions no matter where you are located. In a graph moving one step to the right is always the same distance irregardless of whether I'm at the origin or 80 steps above/below the origin.

As you can see the longitude breaks this assumption and therefore it will produce variably poor results. It is not merely a question of x distance traveled equates to y error, because the scale/magnitude varies depending on where the points are on the globe.

As you can see even though it is appealing to view the GPS coordinate system as a planar graph with a bounding box, the planar graph analogy doesn't work because of how longitude is structured. As such a methodology that would work on a planar graph is wholly inappropriate for a problem utilizing latitude and longitude.

To play on an analogy that whuber made in his answer, treating GPS coordinates like points on a planar graph is like trying to square the circle. Many people have tried, but they were inevitably disappointed.

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