DOC: describe geometry_area_perimeter size limit concretely#1611
Open
Htet-Kaung-San wants to merge 1 commit into
Open
DOC: describe geometry_area_perimeter size limit concretely#1611Htet-Kaung-San wants to merge 1 commit into
Htet-Kaung-San wants to merge 1 commit into
Conversation
The note said only that the function "only works with areas up to half the size of the globe" and that "certain large polygons may return negative values", which does not say what "large" or "certain" mean. Both are the same rule: the area is reduced modulo the total area of the ellipsoid into (-A/2, A/2]. A region covering more than half the ellipsoid therefore comes back as the negated area of its complement -- a polygon enclosing 99% of the globe returns about -1%, not +99%. So "large" means precisely "more than half the ellipsoid" (about 2.55e14 m^2 on WGS84), and shape, proximity to a pole and crossing the antimeridian do not matter on their own. Also cross-reference the existing traversal-direction warning, since that is the other, size-independent reason a result can be negative. Adds a doctest for the wraparound and for recovering the enclosed area. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1592.
The note on
Geod.geometry_area_perimetersaid only:As #1592 points out, that doesn't say what "large" or "certain" mean — whether it's city-sized or continent-sized, and whether shape, poles or the antimeridian are involved.
Both bullets turn out to be the same rule. The area is reduced modulo the total area of the ellipsoid into
(-A/2, A/2], so a region covering more than half the ellipsoid is reported as the negated area of its complement:That polygon is wound counter-clockwise and encloses 99.4% of the globe, but comes back as roughly -0.56% — the thin strip left outside it, negated.
So the answers to the two questions in the issue are concrete:
2.55e14m² on WGS84.I checked the
(-A/2, A/2]bound holds across a grid of boxes spanning ±10° to ±179.9° longitude and ±10° to ±89.9° latitude.The docstring already carries a separate warning that traversal direction is signed, CCW positive. That's the other reason a result can be negative, and unlike the size limit it applies at any size, so I cross-referenced the two rather than describing them independently.
Changes
Documentation only — no behavior change.
Testing
flake8,ruffandcodespellare clean on the changed files, andblacken-docs --skip-errorsleaves them unchanged. The docstring's doctests pass (14 examples, 0 failures), including the two new ones. The99.4%figure is99.4445%before rounding, so it isn't sitting on a rounding boundary.