Search code examples
pythonarraysarea

How to calculate the inside area of a closed shape given a set of coordinates describing the that shape


I have two arrays https://i.sstatic.net/2EyfL.png, first one is y coordinates and the second one is x coordinates, when I plot a diagram with these coordinates, it becomes a closed shape like the attached image https://i.sstatic.net/rOQ7A.png, I'm asking for a way to calculate the inside area of this closed shape in python.


Solution

  • Check out the code here: Calculate area of polygon given (x,y) coordinates

    def PolyArea(x,y):
        return 0.5*np.abs(np.dot(x,np.roll(y,1))-np.dot(y,np.roll(x,1)))