8

I have the array of geographical coordinates (latitude & longitude).

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

Thanks!

Henry
  • 169,616
  • 1
    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
  • 1
    @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

2 Answers2

8

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 \cos \phi_i \sin \lambda_i , R \sin \phi_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{\lambda} = \text{atan2}\left(\bar{y},\bar{x}\right) \text{ and } \bar{\phi} = \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.

Henry
  • 169,616
  • In fact, this is an extrinsic mean. In contrary to the intrinsic one, it is not calculated on the circle itself but in the immersion space. The most appropriate is an intrinsic mean. – Druid Aug 19 '21 at 09:46
  • @Druid - which is most appropriate may depend on the particular situation. This note says "due to its simplicity, greater robustness and the existence of universal, rate-optimal confidence sets for it, the extrinsic mean appears preferable to the intrinsic mean unless one knows in advance that the underlying distribution is unimodal." – Henry Aug 19 '21 at 10:25
  • if the OP had asked for the average of altitude, in addition to latitude and longitude, then the distinction between intrinsic and extrinsic formulations would not seem to matter. – Felipe G. Nievinski Oct 21 '22 at 20:06
0

The variables you mention are points belonging to the manifold, which is the circle. Therefore, they cannot be treated as if they belonged to Euclidean space.

It should also be considered whether we calculate the mean longitude and mean latitude separately or the mean position on the surface of the sphere. It is not the same. There is, of course, an intrinsic mean on the sphere.

I recommend the material that I have prepared on this subject and today I am sharing it on YouTube: Circular means - Introduction to directional statistics.

There are two main types of circular mean: extrinsic and intrinsic.

Extrinsic mean is simply the mean calculated as the centroid of the points in the plane projected onto the circle. $$ \bar{\vec{x}}=\frac{1}{N}\sum_{j=1}^N \vec{x}_j=\frac{1}{N}\sum_{j=1}^N [x_j,y_j]=\frac{1}{N}\sum_{j=1}^N [\cos{\phi_j},\sin{\phi_j}] $$ $$ \hat{\bar{x}}=\frac{\bar{\vec{x}}}{|\bar{x}|} $$ $$ \DeclareMathOperator{\atantwo}{atan2} \bar{\phi}_{ex}=\atantwo(\hat{\bar{x}}) $$ It is NOT a mean calculated using the natural metric along the circle itself.

Intrinsic mean, on the other hand, does have this property. This mean can be obtained by minimizing the Fréchet function. $$ \DeclareMathOperator*{\argmin}{argmin} \bar{\phi}_{in}=\argmin_{\phi_0\in C} \sum_{j=1}^N (\phi_j-\phi_0)^2 $$

For discrete data, you can also analytically determine the $N$ points suspected of being the mean and then compare them using the Fréchet function.

$$ \bar{\phi}_k=\arg \sqrt[N]{\prod_{j=1}^N e^{i\phi_j} }=\bar{\phi}_0+k\frac{2\pi}{N} $$ Where the N-th root is a N-valued function with outputs indexed with $ k\in\{1,\dots,N\} $. They are distributed evenly on the circle. And $ \bar{\phi}_0 $ is a usual mean calculated in an arbitrary range of angle values of length of $2\pi$. If somebody dislikes the complex numbers $$ \bar{\phi}_k=\frac{1}{N} \left(\sum_{j=1}^N \phi_j+k2\pi\right) $$ The result is, of course, the same.

Then you have to compare the points suspected of being the mean using the Fréchet function. $$ \DeclareMathOperator*{\argmin}{argmin} \bar{\phi}_{in}=\argmin_{k\in\{1,\dots,N\}} \sum_{j=1}^N (\phi_j-\bar{\phi}_k)^2 $$ Where the search for minimum runs over $N$ discreet indices.

Druid
  • 161
  • 9