views:

127

answers:

3

I have the lat/lon of 2 points on the earth. They are really close together, <10m. Let's assume the earth is flat. How do I calculate the distance between them in metres?

I know about tools (PostGIS, etc.) that can do this correctly, however I'm just doing a rough and ready type, and I'm OK with low accuracy. At such small sizes a difference of 1% is only 10cm, which is fine for me. I'm doing this in stock python. I'm OK with a standard Euclidean distance thing.

+4  A: 

I'd recommend using the Haversine Formula. Here's a Javascript implementation I've referenced before: http://www.movable-type.co.uk/scripts/latlong.html.

Matt Ball
A: 

Get plane lengths for degrees lat and long from a site like this and, as you suggest, calculate the distances in cartesian coordinates. For distances as small as 10m the inaccuracies in your calculations will be lost in the least significant digits of the results.

High Performance Mark
I want to do this programmatically for thousands of points, so I can't manually check an external site all the time.
Rory
+5  A: 

For such low precision take a look at the pythagorean formulas in article on earth distance.

But, also read some explanations here (for example if the coordinates are not already in Cartesian coordinates it might be computationally cheaper to use Haversine formula).

Unreason
Good links. The unstated assumptions in the Wikipedia "Pythagorean formula with parallel meridians" is that sin(x) = x for small x (angles in radians) and that the earth has a constant radius.
MZB
@MZB, i guess, but it gives the max errors i.e. it states the assumption that the x is so small that the distance is less then 20 km. For 10 m the relative error is even less.
Unreason
@Unreason - just thought it was worth pointing out where the Wiki formula came from. Definitely the simplest approach for such small x.
MZB