Centroid of Geographic Points
Find the mean (centroid) of a list of lat/lng points on the sphere.
Overview
The Centroid of Geographic Points tool takes a list of latitude/longitude coordinates and returns their spherical centroid - the mean point on Earth that sits closest to all of them. Paste in customer addresses, weather stations, hiking checkpoints or store locations, and the tool returns one coordinate that minimises the sum of squared great-circle deviations from the inputs.
Plain averaging of latitudes and longitudes only works for points clustered in a small region. Once your set spans the antimeridian or both hemispheres, naive averages drift badly - a point cloud split between (0, 170) and (0, -170) would average to (0, 0) instead of crossing the date line near (0, 180). This tool sidesteps that problem by working in 3D Cartesian space on the unit sphere and converting the result back to lat/lng, so the centroid behaves sensibly anywhere on the globe.
How it works
Each input point (φ, λ) in degrees is converted to a 3D unit vector (cos φ · cos λ, cos φ · sin λ, sin φ) on the WGS84 sphere. The vectors are summed component-wise and divided by the count to give the mean vector. That mean is then re-projected back to a latitude and longitude with atan2(y, x) for longitude and atan2(z, √(x² + y²)) for latitude.
This is the standard spherical centroid (sometimes called the "centre of mass" on the sphere). It is equal-weighted by default - every point counts the same. Two coincident input points pull the centroid twice as hard as a single isolated one. Points exactly opposite each other (antipodes) produce a degenerate zero vector and the centroid is undefined.
Examples
- Three US coastal cities - Boston, Miami, Seattle - the centroid sits in central Kansas, roughly (40.0, -97.5), reflecting the rough triangle they enclose.
- Four points around the equator at 90 degree spacing - the centroid degenerates to the north pole or undefined, depending on how the vectors cancel.
- Two points near the antimeridian, (0, 179) and (0, -179) - the centroid is (0, 180), correctly straddling the date line instead of collapsing back to (0, 0).
- A dense cluster of 20 points within a single city - the centroid is well inside that city's bounding box and very close to the simple lat/lng average.
FAQ
Is this the same as a weighted centre of population?
No. Each input contributes equally. To weight points - for example by store revenue or station accuracy - duplicate the heavier points in the input list.
How many points can I feed in?
The math is linear in the number of points, so several thousand is fine. The practical limit is browser pasteboard size rather than the algorithm.
Why not just average latitude and longitude?
That works only for small regions far from the poles and the antimeridian. The 3D method is robust everywhere.
What about a centroid for a polygon shape?
Use the polygon area tool's vertex centroid instead. This page calculates the mean of unrelated point samples, not the centroid of a filled shape.