I have a set of points that make up a polygon. I need to find the area and perimeter for the shape in Python. I have used the shapely
library to calculate the area and perimeter but it is nonsensical because the points are latitude and longitude coordinates (in US States).
I need to convert the points to an equal-area projection system first. I was thinking of using Sinusoidal projection. I was able to do this and calculate area (code below), but I'm not sure how to interpret the result (also is it right?). What unit is it in? (m²?)
Next I need to calculate perimeter, but would the Sinusoidal projection distort it and throw it off? How would I deal with that?
I am a computer scientist and my work on a project has led me down this rabbit hole. How can I calculate the area/perimeter of this shape in the correct way?
def sinusoidal(lat, long):
earth_radius = 6371009 # in meters
lat_dist = pi * earth_radius / 180.0
y = lat * lat_dist
x = long * lat_dist * cos(radians(lat))
return x, y
Best Answer
In this link you have an example for determining Geodesic area for a polygon located in antarctic region by using pyproj python3 module. Adapting such script for following polygon (green) in an arbitrary area of USA:
it looks as follows:
After running it in python console, result was as follow:
Obtained values are comparable (differences probably due to different used Geod in each case) to those showed in attributes table of green shapefile (area: 10476912480.580376, perimeter: 418057.541405565).