Skip to content

Instantly share code, notes, and snippets.

@vishalmishra14
Forked from robinkraft/projected_area.py
Created April 29, 2018 17:44
Show Gist options
  • Save vishalmishra14/0f57f90f86dd7369201ee7a3836ed3e4 to your computer and use it in GitHub Desktop.
Save vishalmishra14/0f57f90f86dd7369201ee7a3836ed3e4 to your computer and use it in GitHub Desktop.
get the area in square meters of a polygon using shapely and pyproj
import pyproj
from shapely.geometry import shape
from shapely.ops import transform
geom = {'type': 'Polygon',
'coordinates': [[[-122., 37.], [-125., 37.],
[-125., 38.], [-122., 38.],
[-122., 37.]]]}
s = shape(geom)
proj = partial(pyproj.transform, pyproj.Proj(init='epsg:4326'),
pyproj.Proj(init='epsg:3857'))
s_new = transform(proj, s)
projected_area = transform(proj, s).area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment