title: Calculate the center point of multiple latitude/longitude coordinate pairs
body: <p>Given a set of latitude and longitude points, how can I calculate the latitude and longitude of the center point of that set (aka a point that would center a view on all points)?</p>
  
  <p>EDIT:  Python solution I've used:</p>
  
  <pre class="lang-py prettyprint-override"><code>Convert lat/lon (must be in radians) to Cartesian coordinates for each location.
  X = cos(lat) * cos(lon)
  Y = cos(lat) * sin(lon)
  Z = sin(lat)
  
  Compute average x, y and z coordinates.
  x = (x1 + x2 + ... + xn) / n
  y = (y1 + y2 + ... + yn) / n
  z = (z1 + z2 + ... + zn) / n
  
  Convert average x, y, z coordinate to latitude and longitude.
  Lon = atan2(y, x)
  Hyp = sqrt(x * x + y * y)
  Lat = atan2(z, hyp)
  </code></pre>