← Back to Pull requests

[GH-2230] Implement GeoSeries.clip_by_rect #2784

Closed
unknown closed this pull request without merging on Apr 02, 2026 17:26 UTC
View on GitHub
unknown unknown commented on Mar 25, 2026 09:35 UTC
Author

Did you read the Contributor Guide?

  • Yes, I have read the Contributor Rules and Contributor Development Guide
  • Is this PR related to a ticket?

  • Yes, and the PR name follows the format [GH-XXX] my subject. Part of #2230
  • What changes were proposed in this PR?

    Implement GeoSeries.clip_by_rect(xmin, ymin, xmax, ymax) for the Sedona GeoPandas-compatible API. This clips each geometry in a GeoSeries to the given bounding rectangle, matching the GeoPandas clip_by_rect interface.

    The implementation composes two existing Sedona SQL functions (ST_PolygonFromEnvelope + ST_Intersection) so no new Java/Scala code is needed.

    Files changed:

  • python/sedona/spark/geopandas/geoseries.py — Core implementation + priority list

  • python/sedona/spark/geopandas/base.py — Base class delegation with docstring and examples

  • python/sedona/spark/geopandas/geodataframe.py — Priority list registration

  • python/tests/geopandas/test_geoseries.py — Unit tests (polygon, line, point, None, GeoDataFrame)

  • python/tests/geopandas/test_match_geopandas_series.py — GeoPandas comparison tests over self.geoms
  • How was this patch tested?

  • tests/geopandas/test_geoseries.py::test_clip_by_rect — verifies clipping behavior for polygon, linestring, interior point, exterior point, None, and GeoDataFrame access

  • tests/geopandas/test_match_geopandas_series.py::test_clip_by_rect — iterates over all geometry types in self.geoms and compares Sedona output against GeoPandas (skipping LinearRing, GeometryCollection, and invalid geometries due to JTS/GEOS boundary-handling differences)

  • Full geopandas test suite (pytest tests/geopandas/) — no regressions introduced

  • Pre-commit hooks all pass (make check)
  • Did this PR include necessary documentation updates?

  • No, this PR does not affect any public API documentation — it implements an existing stub method that was already part of the planned API surface (tracked in #2230). A docstring with examples is included inline.
  • Diff: 279 lines (+209 / -70) across 3 files Reviewer: petern48 Review duration: 11991m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 279 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.337
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #2784"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.6% (MEDIUM) · Higher = larger blast radius
    39.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.7% · Safe to merge
    15.7%
    Repository