Skip to content

Instantly share code, notes, and snippets.



Last active May 21, 2021
What would you like to do?
Compute the area of a polygon
def shoelace(poly):
"""Returns the area of the polygon using the shoelace formula"""
s1 = np.sum(poly[:,0] * np.roll(poly[:,1], -1))
s2 = np.sum(poly[:,1] * np.roll(poly[:,0], -1))
return np.absolute(s1 - s2) / 2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment