Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

First, sorry if this questions sound very simple. I am very new to GIS.

Given four values of north/south latitude, east/west longitude how to calculate the center point that is correct for all cases on earth?

                  ----------(north latitude)---------------
                 |                                         |
                 |                                         |
 (west longitude)|                ? (calculate this point) |(east longitude)
                 |                                         |
                 |                                         |
                  ----------(south latitude) --------------

The dateline is an issue if you just use the following formula (N+S)/2 and (E+W)/2 to calculate the center.

share|improve this question

I think you could use the Midpoint formula found at Moveable Type Scripts.

This is the half-way point along a great circle path between the two points.1 Formula:

Bx = cos(φ2).cos(Δλ)
By = cos(φ2).sin(Δλ)
φm = atan2( sin(φ1) + sin(φ2), √((cos(φ1)+Bx)² + By²) )
λm = λ1 + atan2(By, cos(φ1)+Bx)


var Bx = Math.cos(lat2) * Math.cos(dLon);
var By = Math.cos(lat2) * Math.sin(dLon);
var lat3 = Math.atan2(Math.sin(lat1)+Math.sin(lat2),
                      Math.sqrt( (Math.cos(lat1)+Bx)*(Math.cos(lat1)+Bx) + By*By ) ); 
var lon3 = lon1 + Math.atan2(By, Math.cos(lat1) + Bx);
share|improve this answer
+1. Some important details and cautions: (1) "Δλ" is the difference of longitudes, lambda2 - lambda1 (and phi1 and phi2 are latitudes); (2) atan2(y,x) computes an angle whose tangent is y/x (not x/y, as is found in some implementations); (3) in some cases λm must be reduced modulo 360 degrees to lie between -180 and 180 degrees; (4) the formula is correct for the sphere; for an ellipsoid the relative error is good, but the absolute error can be considerable: see… for an analysis. – whuber Mar 22 '13 at 15:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.