Calculation example

This step-by-step example shows how to calculate the geographic midpoint (center of gravity) for three cities: New York, Chicago, and Atlanta. The three cities will be weighted by time.

Convert all coordinates into radians

All latitude and longitude data must be converted into radians. If the coordinates are in degrees.minutes.seconds format, they must first be converted into decimal format. Then convert each decimal latitude and longitude into radians by multiplying each one by PI/180 as in the table below.

CityDMS coordinatesDecimalRadians
New York lat 40° 42' 51.6708" N 40.7143528 0.710599509
New York lon 74° 0' 21.5022" W -74.0059731 -1.291647896
Chicago lat 41° 52' 41.2098" N 41.8781136 0.73091096
Chicago lon 87° 37' 47.2722" W -87.6297982 -1.5294285
Atlanta lat 33° 44' 56.382" N 33.7489954 0.58903108
Atlanta lon 84° 23' 16.7346" W -84.3879824 -1.47284814

weighting factors

The three cities will be weighted by time. For each city, the time is converted into days.
New York, 3 years
w1 = 365.25*3 = 1095.75
Chicago, 2 years
w2 = 365.25*2 = 730.5
Atlanta, 1 year
w3 = 365.25*1 = 365.25

Note that instead of time, a simple weighting factor such as population could also have been stored in w1, w2, and w3. If no weighting factor is desired, set w1=1, w2=1, and w3=1. Now sum the weights for all three cities.

totweight=w1 + w2 + w3
totweight=1095.75 + 730.5 + 365.25 = 2191.5

Convert lat/long to cartesian (x,y,z) coordinates

formulas:
X1 = cos(lat1) * cos(lon1)
Y1 = cos(lat1) * sin(lon1)
Z1 = sin(lat1)

New York:
X1 = cos(0.710599509) * cos(-1.291647896)
= 0.20884915
Y1 = cos(0.710599509) * sin(-1.291647896)
= -0.728630226
Z1 = sin(0.710599509)
= 0.65228829

Chicago:
X2 = cos(0.73091096) * cos(-1.5294285)
= 0.03079231
Y2 = cos(0.73091096) * sin(-1.5294285)
= -0.74392960
Z2 = sin(0.73091096)
= 0.66754818

Atlanta:
X3 = cos(0.58903108) * cos(-1.47284814)
= 0.08131173
Y3 = cos(0.58903108) * sin(-1.47284814)
= -0.82749399
Z3 = sin(0.58903108)
= 0.55555565

Compute combined weighted cartesian coordinate

X = (X1*w1 + X2*w2 + X3*w3)/totweight
= (0.20884915*1095.75 + 0.03079231*730.5 + 0.08131173*365.25)/2191.5
= 0.12824063

Y = (Y1*w1 + Y2*w2 + Y3*w3)/totweight
= ((-0.728630226)*1095.75 + (-0.74392960)*730.5 + (-0.82749399)*365.25)/2191.5
= -0.75020731

Z = (Z1*w1 + Z2*w2 + Z3*w3)/totweight
= (0.65228829*1095.75 + 0.66754818*730.5 + 0.55555565*365.25)/2191.5
= 0.64125282

Convert cartesian coordinate to latitude and longitude for the midpoint

Note that in Excel and possibly some other applications, the two parameters in the atan2 function must be reversed, for example: use atan2(X,Y) instead of atan2(Y,X).

Lon = atan2(y, x)
= (atan2(-0.75020731, 0.12824063)
= -1.40149245

Hyp = sqrt(x * x + y * y)
= sqrt(0.12824063*0.12824063 + (-0.75020731)*(-0.75020731))
= 0.76108913

Lat = atan2(z, hyp)
= atan2(0.64125282, 0.76108913)
= 0.70015084

Convert midpoint lat and lon from radians to degrees

lat= 0.70015084 * (180/PI)
= 40.11568861

lon= -1.40149245* (180/PI)
= -80.29960280

The weighted midpoint is located near Washington, Pennsylvania.

Calculation methods