I've got a series of longitude and latitude coordinates which represent a building outline



...(intermediate points not listed)...


How can I work out the midpoint? I've found tutorials that show how to do it if you've got three coordinates (e.g. http://mathforum.org/library/drmath/view/68373.html), but in many cases I've got more than three.

Thank you

  • 2
    It depends what you mean by "midpoint" - do you mean centroid ?
    – Paul R
    Jul 12 '11 at 14:44
  • 3
    Recommendation: make an attempt yourself, then ask for help when it's not right - give me the answer questions are typically frowned upon here.
    – KevinDTimm
    Jul 12 '11 at 14:46

With coordinates that close to each other, you can treat the Earth as being locally flat and simply find the centroid as though they were planar coordinates. Then you would simply take the average of the latitudes and the average of the longitudes to find the latitude and longitude of the centroid.

Edit: As whuber points out, the above method would not work unless the building is a rectangle or a regular polygon. For an arbitrary shape, the formula here gives the correct result.

  • @murgatroid The observation about not needing a projection is a great one. Unfortunately, averaging the coordinates of the vertices does not give the building's centroid.
    – whuber
    Jul 13 '11 at 18:28
  • @whuber Thanks, I updated my post with the correct method. Jul 13 '11 at 19:29
  • Can you define "close to each other"?
    – kev
    Jun 18 '15 at 3:08

If you want the center of the building which is outlined by a polygon, then don't take the mean of vertices. This is obviously wrong. You need instead to compute the centroid of the polygon itself. For the formula, see


(And, I agree with earlier posters: you can treat latitude and longitude as Cartesian coordinates because the building is small and it's far from a pole and from the international date line.)

  • +1 for providing the important restrictions on the scope of this approximation and for providing a link to formulas. BTW, there is a subtle (but correct) assumption involved in the last recommendation: there is a relative distortion of distances (which can be cured by multiplying the longitudes by the cosines of the latitudes), but for the purpose of computing the centroid this does not matter. (For related calculations, such as finding angles, it would matter a lot.)
    – whuber
    Jul 13 '11 at 14:17
  • Does this technique guarantee a point INSIDE the polygon? I don't know what the final use of the data is, but some uses would require the point to be inside. In that scenario the arithmetic mean most definitely does not guarantee a result (for example the arithmetic centre of Croatia is not even in that country)! Jul 13 '11 at 17:33
  • There's no guarantee that the centroid of a polygon is inside the polygon (except if the polygon is convex, of course).
    – cffk
    Jul 13 '11 at 18:05

Convert from geographic coordinates to geocentric, average the geocentric vectors, then convert back to geographic.

  • 1
    In most applications this calculation would be meaningless because it depends heavily on how the building is represented. For instance, densifying the line segments could change the answer appreciably without changing the building's appearance at all.
    – whuber
    Jul 13 '11 at 18:26

The centroid of finitely many points is simply the arithmetic mean of each of the coordinates. So just sum up the latitudes and longitudes and divide by the number of points.

  • 3
    not if the polygon crosses the dateline Jul 13 '11 at 5:28
  • @Paul @tskuzzy Also, this prescription is not appropriate: the building is not the set of its vertices, it is the interior of the closed polyline traced by those vertices.
    – whuber
    Jul 13 '11 at 18:27

If you're working over larger ranges, you need spherical interpolation.

  • It's difficult to see how that would help. Details?
    – whuber
    Jul 13 '11 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy