Skip to content

[GH-2527] Implement GeoPandas concave_hull - #2529

Merged
jiayuasu merged 6 commits into
apache:masterfrom
chay0112:feature/concave-hull-implementation
Jul 20, 2026
Merged

[GH-2527] Implement GeoPandas concave_hull#2529
jiayuasu merged 6 commits into
apache:masterfrom
chay0112:feature/concave-hull-implementation

Conversation

@chay0112

Copy link
Copy Markdown
Contributor

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

  • Implement concave_hull functionality

How was this patch tested?

  • Included unit and parity tests

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation.

@chay0112

chay0112 commented Nov 26, 2025

Copy link
Copy Markdown
Contributor Author

Hi @petern48

I'm encountering a test failure in our Sedona/GeoPandas parity suite for concave_hull(Passing in my local). The error is due to the vertex order of polygons returned by Sedona and GeoPandas being different, even though the polygons are geometrically identical. Our current comparison uses equals_exact(assert_geometry_almost_equal), which might be sensitive to vertex order:

=========================== short test summary info ============================ FAILED tests/geopandas/test_match_geopandas_series.py::TestMatchGeopandasSeries::test_concave_hull - ValueError: Geometry equality check failed for POLYGON ((1 4, 3 4, 4 4, 3 1, 4 0, 0 0, 1 1, 0 4, 1 4)) and POLYGON ((1 4, 3 4, 4 4, 4 0, 3 1, 0 0, 1 1, 0 4, 1 4))

https://github.com/apache/sedona/actions/runs/19687051539/job/56394868966?pr=2529

Would it be acceptable to change our comparison from equals_exact to equals for polygons, so that we check geometric equality rather than strict vertex order? Or is there a recommended workaround for this situation, or something I might be missing in our test setup?

Thank you for your guidance!

Comment thread python/tests/geopandas/test_match_geopandas_series.py
Comment thread python/tests/geopandas/test_match_geopandas_series.py Outdated
Comment thread python/tests/geopandas/test_geoseries.py Outdated
@petern48

Copy link
Copy Markdown
Member

Would it be acceptable to change our comparison from equals_exact to equals for polygons, so that we check geometric equality rather than strict vertex order? Or is there a recommended workaround for this situation, or something I might be missing in our test setup?

The issue is not whether we're using equals_exact() or equals(). If you give it a try, you'll see that the comparison fails either way. Despite the name, equals_exact is actually more lenient, since it supports a tolerance parameter.

Script to test using equals instead
import shapely
geom1 = shapely.wkt.loads("POLYGON ((1 4, 3 4, 4 4, 3 1, 4 0, 0 0, 1 1, 0 4, 1 4))")
geom2 = shapely.wkt.loads("POLYGON ((1 4, 3 4, 4 4, 4 0, 3 1, 0 0, 1 1, 0 4, 1 4))")
print(geom1.equals(geom2))  # False
print(geom1.equals_exact(geom2, 0.000001))  # False
Images to visualize the different results image image

As you can see above, these geometries actually are different. Why this is happening, I'm not sure. It could either be a bug in Sedona's function or a difference in algorithms or edge case behaviors. If it's a significant bug, we may want to hold off. If it's a reasonable difference in behavior that's still correct, we can add a note in the docs and merge this anyway. Either way, we need to understand what's happening before merging. I encourage you to investigate, though you're not obligated to, of course, and can continue with something else instead.

Copilot AI 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.

Pull request overview

Implements and hardens concave_hull parity for the Sedona GeoPandas API by refining Python-side typing/docs and expanding unit/parity test coverage (including allow_holes=True cases) to better match GeoPandas behavior.

Changes:

  • Expanded GeoPandas parity tests to cover multiple ratio values and an allow_holes=True fixture designed to avoid JTS/GEOS triangulation tie ambiguity.
  • Added a deterministic allow_holes=True concave hull expectation in GeoSeries unit tests.
  • Added a return type annotation for GeoSeries.concave_hull and improved end-user docstring content.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
python/tests/geopandas/test_match_geopandas_series.py Extends parity tests for concave_hull across ratio values and validates allow_holes=True behavior.
python/tests/geopandas/test_geoseries.py Adds a dedicated allow_holes=True concave hull assertion with an asymmetric point set.
python/sedona/spark/geopandas/geoseries.py Adds GeoSeries return type annotation for concave_hull.
python/sedona/spark/geopandas/base.py Updates concave_hull docstring (but currently contains a misleading algorithm/parameter explanation).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/sedona/spark/geopandas/base.py Outdated
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Jul 20, 2026
@jiayuasu jiayuasu changed the title [GH-2527] Implement concave_hull [GH-2527] Implement GeoPandas concave_hull Jul 20, 2026
@jiayuasu
jiayuasu merged commit 93c7324 into apache:master Jul 20, 2026
34 checks passed
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.

Geopandas: Implement concave_hull

4 participants