[polygons] Polygon area calculations

This commit is contained in:
Al
2015-10-28 21:19:35 -04:00
parent e946e63222
commit 110451d6d6

View File

@@ -0,0 +1,26 @@
import pyproj
from functools import partial
from shapely.ops import transform
from shapely.geometry import Polygon
def polygon_area(poly):
return transform(
partial(pyproj.transform,
pyproj.Proj(init='EPSG:4326'),
pyproj.Proj(proj='aea',
lat1=poly.bounds[1],
lat2=poly.bounds[2],
)
),
poly
).area
def polygon_bounding_box_area(poly):
bbox = poly.bounds
p = Polygon([(bbox[0], bbox[3]), (bbox[0], bbox[1]),
(bbox[2], bbox[1]), (bbox[2], bbox[3]),
])
return polygon_area(p)