fix: restore Polygon cutline schema for Shapely 2#2044
Merged
Conversation
Shapely 2 no longer has `__getitem__` for MultiPolygon, so unary_union results were written whole instead of picking the largest polygon. Commit 75a1e1f only fixed one half of that mismatch by changing the schema to MultiPolygon; Fiona 1.9+ still rejects Polygon records against a MultiPolygon schema. Use .geoms to select the largest polygon and declare the GPKG layer as Polygon again.
|
|
||
| class TestCutline(unittest.TestCase): | ||
| def test_largest_polygon_from_single_polygon(self): | ||
| p = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)]) |
Member
There was a problem hiding this comment.
Usually, I would add some comments and/or "ASCII" art to visualise what is going on.
Right now the tests are not super clear to me.
Contributor
Author
There was a problem hiding this comment.
Added a few more comments to explain what was going on 👍
DodgySpaniard
approved these changes
Jul 2, 2026
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.
Fix split-merge cutline GPKG writes failing under Shapely 2 + Fiona 1.9+.
This came up with running OATS
brighton_split_mergetest:The root cause is related to two dependency bumps we did in #1958 - Shapely 2 no longer has
__getitem__forMultiPolygonand sounary_unionresults were written whole instead of picking the largest polygon. Commit 75a1e1f only fixed one half of that mismatch by changing the schema toMultiPolygonbut Fiona 1.9+ still rejectsPolygonrecords against aMultiPolygonschema.Note #1958 testing originally hit the opposite mismatch (
MultiPolygonrecord vsPolygonschema) before 75a1e1f; this PR fixes both directions by fixing Shapely unpacking and restoring the Polygon schema.