Skip to content

FIX: use shoelace formula for input polygons - #2741

Merged
greglucas merged 1 commit into
SciTools:mainfrom
rcomer:shoelace-in
Sep 14, 2026
Merged

greglucas merged 1 commit into
SciTools:mainfrom
rcomer:shoelace-in

Conversation

@rcomer

@rcomer rcomer commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Rationale

Following #2665, also use the more robust shoelace formula when checking the direction of polygons before we transform them.

Fixes #2312. In that example, when projecting the data before calling contourf we get

image

If we call contourf on the original data, with main we get

image

and with this branch we get

image

I wrote this branch back in April and saw 179 test failures. Those are now gone, but I have not tracked down why. I checked what happened if I apply the change to the commit just before #2653, but that also passed. Edit: it's possible I was running with proj 9.8 so was mistaken that the branch caused the failures.

Implications

@rcomer

rcomer commented Sep 14, 2026

Copy link
Copy Markdown
Member Author

I do not understand the MacOS failure, but I also do not think it is related to this change as it has to do with creating a CRS object.

@greglucas greglucas left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is another one in patch.py, should we apply it there too?

@rcomer

rcomer commented Sep 14, 2026

Copy link
Copy Markdown
Member Author

I'm inclined to leave the one in patch.py alone: the function is deprecated and there appear to be no tests covering force_ccw=True, which is the case when the check is used. It would almost certainly do no harm to change it, but the lack of coverage makes me twitchy.

@greglucas

Copy link
Copy Markdown
Contributor

Ahh yes, I forgot that was deprecated. Sounds good!

@greglucas
greglucas merged commit 164dafb into SciTools:main Sep 14, 2026
47 of 48 checks passed
@rcomer
rcomer deleted the shoelace-in branch September 14, 2026 14:39
@rcomer rcomer added this to the 0.26 milestone Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

contourf fails with lat/lon coordinates and transform for Stereographic projection but works correctly with projection coordinates

2 participants