Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a database with locations with its lat and long coordinates. The area of locations is quite small with lots of them quite near each other.

Im using this stored procedure in my project.

I'm having troubles with accurancy. I need it to return more accurate results (in metres) instead of just 0 distance.

Can it be modified so I get better results? Thank you

share|improve this question
Your link brings up a giant page full of links, not a specific proc, so it is hard to be helpful. – bmargulies Jul 31 '10 at 16:17
Which version of MySQL, and have you tried using double precision? – Rowland Shaw Jul 31 '10 at 16:43
See also:… – Rowland Shaw Jul 31 '10 at 16:45
I'm using MySQL 5.0.67. – Mishal Aug 2 '10 at 8:49
up vote 2 down vote accepted

If the distances are so close together that single precision floats can't capture the distance, you probably don't need to account for the curvature of the earth at all — you must be dealing with phenomena only a few meters apart. The simplest solution is to then use double precision, as Rowland mentioned, or easier yet, just compute a linear distance between the two points, ignoring earth curvature.

In the highly unlikely event that you do in fact have high-precision, high-accuracy data, you can use the Vincenty's formula, which can give accurate results down to millimeters.

share|improve this answer
OK, I will try it and post my findings here. – Mishal Aug 2 '10 at 8:50
Cool, Vincenty's formula works good. Prepared procedure for MySQL can be found here: – Mishal Aug 2 '10 at 10:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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