Created
December 29, 2014 17:05
-
-
Save selimnairb/1e25fee5a19ca5fe62f2 to your computer and use it in GitHub Desktop.
Calculate the area of a geodesic polygon defined by WGS84 coordinates using Python version of GeographicLib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See http://geographiclib.sourceforge.net for more information | |
from geographiclib.polygonarea import PolygonArea | |
from geographiclib.geodesic import Geodesic | |
coords = [(-81.684594, 35.725673), | |
(-80.059151, 35.725673), | |
(-80.059151, 36.689994), | |
(-81.684594, 36.689994)] | |
polyArea = PolygonArea(Geodesic.WGS84, False) | |
for coord in coords: | |
polyArea.AddPoint(coord[1], coord[0]) | |
result = polyArea.Compute(False, False) | |
print("GeographicLib area {0:.2f}-km2".format(result[2]/1000/1000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment