Skip to content

[GH-2230] Add GeoSeries.shortest_line and GeoSeries.offset_curve#2828

Merged
jiayuasu merged 3 commits intoapache:masterfrom
jiayuasu:feature/geopandas-shortest-line-offset-curve
Apr 8, 2026
Merged

[GH-2230] Add GeoSeries.shortest_line and GeoSeries.offset_curve#2828
jiayuasu merged 3 commits intoapache:masterfrom
jiayuasu:feature/geopandas-shortest-line-offset-curve

Conversation

@jiayuasu
Copy link
Copy Markdown
Member

@jiayuasu jiayuasu commented Apr 7, 2026

What is the link to the JIRA/GitHub issue?

Closes #2230 (partial — adds offset_curve and shortest_line)

What changes were proposed in this pull request?

Adds GeoPandas-compatible GeoSeries.offset_curve() and GeoSeries.shortest_line() methods to the Sedona GeoPandas-on-Spark layer:

  • offset_curve(distance, quad_segs, join_style, mitre_limit) backed by ST_OffsetCurve, with empty-geometry handling to return LINESTRING EMPTY (preserving SRID) instead of null.
  • shortest_line(other, align) backed by ST_ShortestLine, supporting GeoSeries-to-GeoSeries and GeoSeries-to-scalar geometry usage.

Both methods are exposed on GeoSeries and GeoDataFrame via the base class delegation pattern.

How was this patch tested?

  • Unit tests in test_geoseries.py covering GeoSeries-to-GeoSeries, GeoSeries-to-scalar, and GeoDataFrame delegation.
  • Cross-implementation comparison tests in test_match_geopandas_series.py validating output matches native GeoPandas for all geometry types.
  • All tests pass locally with PySpark 3.4 / Python 3.10.

Did this PR include necessary documentation updates?

Docstrings added in base.py following the existing GeoPandas-style convention.

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.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 by ST_OffsetCurve, including special-casing empty inputs to return LINESTRING EMPTY.
  • Implement GeoSeries.shortest_line(other, align=None) backed by ST_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.

@jiayuasu
Copy link
Copy Markdown
Member Author

jiayuasu commented Apr 7, 2026

Addressed all review comments in 647a25c:

  1. geoseries.py:1064 — Scalar-only distance is correct; GeoPandas offset_curve also only accepts scalar. Updated the docstring accordingly.
  2. base.py:1006 — Fixed docstring from float or array-like to float.
  3. base.py:1015 — Already documented: the join_style/mitre_limit compatibility note was present in the docstring.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@jiayuasu jiayuasu added this to the sedona-1.9.0 milestone Apr 8, 2026
@jiayuasu jiayuasu merged commit 9cddeab into apache:master Apr 8, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[EPIC] Implement More Geopandas Functions

2 participants