1

I have two latitude, longitude, now how i can find the center latitude,longitude of that two latitude longitude. Can anybody help me?

Soumitra
  • 185
  • 5
  • 11

3 Answers3

3

Define what is 'center' for you. Mostly, i use simple average. Better solution is to compute two vectors (from center of the earth), add them and normalize result. Calculate the center point of multiple latitude/longitude coordinate pairs

Community
  • 1
  • 1
2

Also, be careful about longitudes. The midpoint between two points at 170° E and 170° W should be at 180° E (or W), but you may end up with 0° E.

Download Map Projections: A Working Manual, by John P. Snyder, from the USGS. http://pubs.er.usgs.gov/publication/pp1395. It's free.

Eric Jablow
  • 7,874
  • 2
  • 22
  • 29
1

Convert your latitudes and longitudes to radians, then

$deltaLongitude = $endPointLongitude - $startPointlongitude;

$xModified = cos($endPointLatitude) * cos($deltaLongitude);
$yModified = cos($endPointLatitude) * sin($deltaLongitude);

$midpointLatitude = atan2(
    sin($startPointlatitude) + sin($endPointLatitude),
    sqrt((cos($startPointLatitude) + $xModified) * (cos($startPointLatitude) + $xModified) + 
         $yModified * $yModified
    )
);
$midpointLongitude = $startPointLongitude +
    atan2($yModified, 
        cos($startPointLatitude) + $xModified
    );
Mark Baker
  • 209,507
  • 32
  • 346
  • 385