Calculation Methods
This page shows how to calculate the geographic midpoint (also known as the geographic center, or center of gravity) for two or more points on the earth's surface. A second method is given showing how to calculate the center of minimum distance^{**}, and finally a third method calculates the average latitude/longitude. There are reasons for choosing one method over another. The first two methods assume that the earth is a perfect sphere, which yields sufficiently accurate results for most purposes. In contrast, the third method uses a flat earth model.
We will assume that the latitude and longitude data for the calculations comes from a list called 'Your places'. Each location may be weighted in one of three ways:
 Weight by time. Use this to specify the amount of time you have lived in each location in order to find the geographic average location for all of the places you have lived in. The time for each location is converted into days, for example: w_{1} = years*365.25 + months*0.4375 + days.
 Simple weighting factor, such as population for each location can be stored in w_{1}, w_{2} etc.
 Equal weight. If no location is to be weighted more than another then set w_{1}, w_{2} etc all = 1.
A. Geographic midpoint
Note: See this example showing stepbystep numerical calculations using real latitude and longitude data. The formulas below show how to weight by time.
Summary
The geographic midpoint is calculated by finding the center of gravity for the locations in the 'Your Places' list. The latitude and longitude for each location is converted into Cartesian (x,y,z) coordinates. The x,y, and z coordinates are then multiplied by the weighting factor and added together. A line can be drawn from the center of the earth out to this new x, y, z coordinate, and the point where the line intersects the surface of the earth is the geographic midpoint. This surface point is converted into the latitude and longitude for the midpoint.
Details

Given the values for the first location in the list:
Lat_{1}, lon_{1}, years_{1}, months_{1} and days_{1}
Convert Lat_{1} and Lon_{1} from degrees to radians.
lat_{1} = lat_{1} * PI/180
lon_{1} = lon_{1} * PI/180 
Convert lat/lon to Cartesian coordinates for first location.
X_{1} = cos(lat_{1}) * cos(lon_{1})
Y_{1} = cos(lat_{1}) * sin(lon_{1})
Z_{1} = sin(lat_{1}) 
Compute weight (by time) for first location.
w_{1}= (years_{1} * 365.25) + (months_{1} * 30.4375) + days_{1}
If locations are to be weighted equally, set w_{1}, w_{2} etc all equal to 1.  Repeat steps 13 for all remaining locations in the list.

Compute combined total weight for all locations.
Totweight = w_{1} + w_{2} + ... + w_{n} 
Compute weighted average x, y and z coordinates.
x = ((x_{1} * w_{1}) + (x_{2} * w_{2}) + ... + (x_{n} * w_{n})) / totweight
y = ((y_{1} * w_{1}) + (y_{2} * w_{2}) + ... + (y_{n} * w_{n})) / totweight
z = ((z_{1} * w_{1}) + (z_{2} * w_{2}) + ... + (z_{n} * w_{n})) / totweight 
Convert average x, y, z coordinate to latitude and longitude. Note that in Excel and possibly some other applications, the parameters need to be reversed in the atan2 function, for example, use atan2(X,Y) instead of atan2(Y,X).
Lon = atan2(y, x)
Hyp = sqrt(x * x + y * y)
Lat = atan2(z, hyp) 
Convert lat and lon to degrees.
lat = lat * 180/PI
lon = lon * 180/PI 
Special case:
If abs(x) < 10^{9} and abs(y) < 10^{9} and abs(z) < 10^{9} then the geographic midpoint is the center of the earth.
Notes for method A
The (x,y,z) coordinate system is based on the xy plane lying within the equatorial plane, with its origin at the center of the earth. Looking down onto the North Pole, the positive xaxis passes through the Greenwich meridian (0°E), the positive yaxis passes through the 90°E meridian, and the positive zaxis extends from the center of the earth through the North Pole. The calculations use a unit radius (radius = 1) for the earth. Absolute cartesian coordinates in miles or km can be obtained by multiplying x, y and z by the radius of the earth. Most computer applications require that latitude and longitude data be converted to radians before using them in the trig functions.
B. Center of minimum distance
This method uses a mathematical algorithm to find the exact point that minimizes the total travel distance from all locations in 'Your Places'. The mathematical implementation of this algorithm is fairly complex, but the general steps are described below. All distances are calculated using the spherical law of cosines given below.
Description
 Let CurrentPoint be the geographic midpoint found in Method A. this is used as the starting point for the search.
 Let MinimumDistance be the sum total of all distances from the current point to all locations in 'Your Places'.
 Find the total distance between each location in 'Your Places' and all other locations in 'Your Places'. If any one of these locations has a new smallest distance then that location becomes the new CurrentPoint and MinimumDistance.
 Let TestDistance be PI/2 radians (6225 miles or 10018 km).
 Find the total distance between each of 8 test points and all locations in 'Your Places'. The test points are arranged in a circular pattern around the CurrentPoint at a distance of TestDistance to the north, northeast, east, southeast, south, southwest, west and northwest.
 If any of these 8 points has a new smallest distance then that point becomes the new CurrentPoint and MinimumDistance and go back to step 5 using that point.
 If none of the 8 test points has a new smallest distance then divide TestDistance by 2 and go back to step 5 using the same point.
 Repeat steps 5 to 7 until no new smallest distance can be found or until TestDistance is less than 0.00000002 radians.
Spherical law of cosines
distance = acos(sin(lat_{1})*sin(lat_{2}) + cos(lat_{1})*cos(lat_{2})*cos(lon_{2}  lon_{1}))
C. Average latitude/longitude
This method finds a simple average latitude and longitude for the locations in 'Your Places'. This is equivalent to finding a midpoint on a flat rectangular projection map. When the distance between locations is less than 250 miles (400 km), this method gives a close approximation to the true geographic midpoint in Method A.
Details
 Use the values calculated in Method A for each location: lat_{1} to lat_{n}, lon_{1} to lon_{n}, w_{1} to w_{n}, and totweight.

All longitudes in 'Your Places' are adjusted so as to be relative to the geographic midpoint longitude calculated in Method A. This helps eliminate the problems associated with locations on both sides of the International Date Line. For example:
lon_{1} = lon_{1}  lon_{GeographicMidpoint}
then if the resulting lon_{1} lies outside the range 180 to 180, then add or subtract 360 to bring it back into that range. 
Calculate the weighted latitude and longitude.
lat = (lat_{1}*w_{1} + lat_{2}*w_{2} + ... + lat_{n}*w_{n})/totweight
lon = (lon_{1}*w_{1} + lon_{2}*w_{2} + ... + lon_{n}*w_{n})/totweight

Add the longitude of the geographic midpoint to return the calculated longitude to its original reference:
lon = lon + lon_{GeographicMidpoint}
Add or subtract 360 from lon if it falls outside the range 180 to 180.
^{**}The center of minimum distance concept and algorithm developed by GeoMidpoint.
Geographic Midpoint Calculator
See how the midpoint calculations can work in real life with this free online application. With the Geographic Midpoint Calculator you can find the midpoint of an airline flight between two cities. You can also find your personal center of gravity by selecting all of the locations that you have lived in, then view all of those locations displayed on a map along with a marker pointing at the location of your exact personal center of gravity.
Random Point Generator With Maps
The Random Point Generator generates points at random locations on the surface of the earth. You can throw one or more virtual darts at a Google map and see where they land at.
Random point generator calculation methods
Let's meet in the middle
This free tool finds the ideal restaurant or other point of interest halfway between two or more addresses. Meet your friend or business acquaintance for lunch.