Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. 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 the array of geographical coordinates (latitude & longitude).

What is the best way to calculate average latitude and longitude?


share|cite|improve this question
Any reason why the arithmetic mean will not do? (Take north latitude as positive and south latitude as negative; take east longitude as positive and west longitude as negative, if that's an issue) – Arturo Magidin Jun 26 '11 at 22:05
@Arturo: There might be a problem if for example all of the points are in the Pacific but the average longitude is in Africa. – Henry Jun 26 '11 at 22:09
up vote 4 down vote accepted

This is a question of directional statistics. Similar issues arise with the average of circular quantities.

The conventional method is to convert latitudes ($\phi_i$) and longitudes ($\lambda_i$) into three dimensional points $(x_i,y_i,z_i)$ using

$$(R \cos \phi_i \cos \lambda_i, R \sin \phi_i \cos \lambda_i , R \sin \lambda_i )$$

then take the mean of these points $(\bar{x},\bar{y},\bar{z})$, generally giving you a point inside the sphere, and then converting this direction back to latitude and longitude, using something like $$\bar{\phi} = \text{atan2}\left(\bar{y},\bar{x}\right) \text{ and } \bar{\lambda} = \text{atan2}\left(\bar{z},\sqrt{\bar{x}^2+\bar{y}^2}\right). $$

Proportionately how far the mean point is inside the sphere, i.e. $\frac{\sqrt{\bar{x}^2+\bar{y}^2+\bar{z}^2}}{R}$, is an indicator of dispersion of the original points.

share|cite|improve this answer
That's what I needed. Thank you! – romaonthego Jun 26 '11 at 23:16

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.