Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate area of arbitrary polygon on Earth's surface #1401

Open
jonathan-geoseer opened this issue May 14, 2024 · 4 comments
Open

Calculate area of arbitrary polygon on Earth's surface #1401

jonathan-geoseer opened this issue May 14, 2024 · 4 comments
Labels
documentation Docs need updating proj Bug or issue related to PROJ proposal Idea for a new feature. question

Comments

@jonathan-geoseer
Copy link

geometry_area_perimeter has limitations that means it cannot calculate the area of many polygons:
https://pyproj4.github.io/pyproj/stable/api/geod.html#pyproj.Geod.geometry_area_perimeter

Suggestion:
A method/function/class that allows calculation of the area of a polygon anywhere on the earth's surface (in m^2). Should scale up to global-coverage sized polygons.

This is a fairly commonly sought use-case: https://gis.stackexchange.com/questions/127607/calculating-area-in-km%C2%B2-for-polygon-in-wkt-using-python - I don't believe any of the answers on there work any more, so maybe this should be a bug (regression), rather than a feature request?

@jonathan-geoseer jonathan-geoseer added the proposal Idea for a new feature. label May 14, 2024
@snowman2 snowman2 added question documentation Docs need updating labels May 15, 2024
@snowman2
Copy link
Member

This is calculated using geod_polygonarea. This code originated from: https://geographiclib.sourceforge.io/. It is likely that your request would be best handled upstream.

@snowman2 snowman2 added the proj Bug or issue related to PROJ label May 15, 2024
@snowman2
Copy link
Member

I don't believe any of the answers on there work any more

What issues are you seeing?

@jonathan-geoseer
Copy link
Author

What issues are you seeing?

Five of the answers use a combination of shapely.ops.transform, pyproj.transform, and partial - This is what I used to use, but upon upgrading the shapely version to 2.x, I was getting a lot of errors and the results were wrong. I assume something was deprecated, I forget the details.

Other option is geod = Geod(ellps="WGS84") - which doesn't work on 50% of shapes (see bug ticket this suggestion comes from).

https://pypi.org/project/area/ - this is what I'm now using.

@snowman2
Copy link
Member

upon upgrading the shapely version to 2.x, I was getting a lot of errors and the results were wrong

This upgrade guide should resolve your issues:
https://shapely.readthedocs.io/en/stable/manual.html#shapely.ops.transform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Docs need updating proj Bug or issue related to PROJ proposal Idea for a new feature. question
Projects
None yet
Development

No branches or pull requests

2 participants