The solution proposed by Pierre-Luc Champigny is incorrect.
In the following figure, you can see two lines:
- (lat1, lon1) → (lat2, lon2)
- (lat1, lon2) → (lat2, lon1)
Half the length of each line is green, the other half is blue.
You can see that the center of both lines is not the same point, and both centers are not the centers of the polygon.

To find the center of a polygon:
- lat = avrg (lat1, lat2)
- lon = avrg (lon1, lon2)
To get these values, you can use the link suggested by Pierre-Luc Champigny, but:
- Take lat midpoint (lat1, lon1) -> (lat2, lon1)
- Take lon mid (lat1, lon1) -> (lat1, lon2)
source share