[GH-2230] Add GeoSeries.shortest_line and GeoSeries.offset_curve#2828
Merged
jiayuasu merged 3 commits intoapache:masterfrom Apr 8, 2026
Merged
Conversation
Implement GeoPandas counterparts for ST_ShortestLine and ST_OffsetCurve: - shortest_line: binary operation returning the shortest line between two geometries, delegating to ST_ShortestLine - offset_curve: unary operation returning a line at a given offset distance from a linear geometry, delegating to ST_OffsetCurve. Handles empty geometries by returning LINESTRING EMPTY to match GeoPandas behavior. Add tests in both test_geoseries.py and test_match_geopandas_series.py.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds GeoPandas-compatible GeoSeries operations for computing (1) offset curves for linear geometries and (2) shortest connecting lines between geometries, implemented in the Sedona GeoPandas-on-Spark layer and validated against native GeoPandas behavior.
Changes:
- Implement
GeoSeries.offset_curve(...)backed byST_OffsetCurve, including special-casing empty inputs to returnLINESTRING EMPTY. - Implement
GeoSeries.shortest_line(other, align=None)backed byST_ShortestLine, supporting GeoSeries-to-GeoSeries and GeoSeries-to-scalar geometry usage. - Add unit and compatibility tests for both methods.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
python/sedona/spark/geopandas/geoseries.py |
Adds the concrete Spark-backed implementations for offset_curve and shortest_line. |
python/sedona/spark/geopandas/base.py |
Exposes the APIs on the base class with GeoPandas-style docstrings and delegation for GeoSeries/GeoDataFrame. |
python/tests/geopandas/test_geoseries.py |
Adds focused functional tests for the new methods, including GeoDataFrame delegation. |
python/tests/geopandas/test_match_geopandas_series.py |
Adds cross-implementation comparison tests vs native GeoPandas for both methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Member
Author
|
Addressed all review comments in 647a25c:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
What is the link to the JIRA/GitHub issue?
Closes #2230 (partial — adds
offset_curveandshortest_line)What changes were proposed in this pull request?
Adds GeoPandas-compatible
GeoSeries.offset_curve()andGeoSeries.shortest_line()methods to the Sedona GeoPandas-on-Spark layer:offset_curve(distance, quad_segs, join_style, mitre_limit)backed byST_OffsetCurve, with empty-geometry handling to returnLINESTRING EMPTY(preserving SRID) instead ofnull.shortest_line(other, align)backed byST_ShortestLine, supporting GeoSeries-to-GeoSeries and GeoSeries-to-scalar geometry usage.Both methods are exposed on
GeoSeriesandGeoDataFramevia the base class delegation pattern.How was this patch tested?
test_geoseries.pycovering GeoSeries-to-GeoSeries, GeoSeries-to-scalar, and GeoDataFrame delegation.test_match_geopandas_series.pyvalidating output matches native GeoPandas for all geometry types.Did this PR include necessary documentation updates?
Docstrings added in
base.pyfollowing the existing GeoPandas-style convention.