[GH-2765] Implement GeoSeries: relate_pattern, contains_properly, build_area, polygonize#2766
[GH-2765] Implement GeoSeries: relate_pattern, contains_properly, build_area, polygonize#2766
Conversation
…a, polygonize Tier 2 batch F/G: implements 4 remaining Tier 2 GeoSeries functions. - relate_pattern(other, pattern): delegates to ST_Relate 3-arg form - contains_properly(other): implemented via ST_Relate with DE-9IM pattern T**FF*FF* (no ST_ContainsProperly in Sedona) - build_area(node=True): aggregate operation matching geopandas semantics; collects all linework, builds areas, explodes into polygons - polygonize(node=True, full=False): aggregate operation matching geopandas semantics; collects all linework, polygonizes, explodes results Includes unit tests and geopandas match tests for all 4 functions.
There was a problem hiding this comment.
Pull request overview
Implements four missing GeoSeries methods in Sedona’s GeoPandas-compatibility layer, wiring them to Sedona SQL functions and extending the test suite to validate behavior against real GeoPandas outputs (GH-2765).
Changes:
- Added GeoSeries aggregation methods
build_area()andpolygonize()backed byST_BuildArea/ST_Polygonizewith optional noding viaST_Union_AggrvsST_Collect_Agg. - Added GeoSeries binary predicates
relate_pattern()andcontains_properly()backed by the 3-argST_Relatepredicate form. - Added unit and “match GeoPandas” tests for the new methods.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
python/sedona/spark/geopandas/base.py |
Adds GeoSeries API surface + docstrings delegating to the geometry column implementation. |
python/sedona/spark/geopandas/geoseries.py |
Implements Sedona-backed logic for the four new GeoSeries methods. |
python/tests/geopandas/test_geoseries.py |
Adds unit tests for new methods and GeoDataFrame delegation checks. |
python/tests/geopandas/test_match_geopandas_series.py |
Adds comparison tests to ensure Sedona GeoSeries matches GeoPandas outputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…a/polygonize - Replace driver-side shapely.get_parts() with Spark-side explode(ST_Dump(...)) to keep results distributed - Pass crs=self.crs to returned GeoSeries to preserve SRID/CRS - Import InternalField at module level
There was a problem hiding this comment.
Pull request overview
Implements four missing GeoSeries APIs in Sedona’s GeoPandas-compatibility layer, mapping them to Sedona SQL functions and adding both unit tests and GeoPandas parity (“match”) tests for correctness.
Changes:
- Add aggregate GeoSeries methods
build_area(node)andpolygonize(node, full)backed byST_(Union/Collect)_Aggr+ST_(BuildArea/Polygonize)and Spark-sideST_Dumpexploding. - Add binary predicate methods
relate_pattern(other, pattern, align)andcontains_properly(other, align)backed byST_Relate(..., pattern). - Add unit tests and GeoPandas comparison tests for the above methods.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
python/sedona/spark/geopandas/geoseries.py |
Implements the four new GeoSeries methods using Sedona SQL functions and Spark-side explosion into polygons. |
python/sedona/spark/geopandas/base.py |
Adds public GeoSeries API surface (docstrings + delegation) for the new methods. |
python/tests/geopandas/test_geoseries.py |
Adds unit tests for build_area/polygonize + contains_properly/relate_pattern. |
python/tests/geopandas/test_match_geopandas_series.py |
Adds GeoPandas parity tests for build_area/polygonize + contains_properly/relate_pattern. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace sdf.head(1) is None (never true) with sdf.take(1) - Single Spark action instead of two
There was a problem hiding this comment.
Pull request overview
Implements four missing GeoSeries methods in Sedona’s GeoPandas-compatibility layer by delegating to corresponding Sedona ST_* functions, and adds unit + “match GeoPandas output” tests to validate behavior.
Changes:
- Add GeoSeries aggregation methods
build_area(node)andpolygonize(node, full)backed byST_Union_Aggr/ST_Collect_Agg+ST_BuildArea/ST_PolygonizeandST_Dump. - Add GeoSeries binary predicate methods
contains_properly(other, align)andrelate_pattern(other, pattern, align)backed by 3-argST_Relate. - Add unit tests and GeoPandas comparison tests for the new 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 | Implements the Spark-side logic for build_area, polygonize, contains_properly, and relate_pattern. |
| python/sedona/spark/geopandas/base.py | Adds GeoPandas-style public API surface + docstrings delegating to the geometry column implementation. |
| python/tests/geopandas/test_geoseries.py | Adds unit tests for new GeoSeries methods, including empty-series and GeoDataFrame delegation checks. |
| python/tests/geopandas/test_match_geopandas_series.py | Adds GeoPandas output parity tests for build_area, polygonize, contains_properly, and relate_pattern. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Implements four missing GeoSeries methods in Sedona’s GeoPandas-compatibility layer by delegating to Sedona SQL functions, with corresponding unit tests and GeoPandas match tests to validate behavior and API parity.
Changes:
- Added aggregate constructors
build_area(node)andpolygonize(node, full)backed byST_Union_Aggr/ST_Collect_Agg+ST_BuildArea/ST_Polygonizeand Spark-sideST_Dumpexplosion. - Added binary predicates
relate_pattern(other, pattern, align)andcontains_properly(other, align)backed by 3-argST_Relate. - Added/updated unit tests and GeoPandas parity (“match”) tests for the new methods.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/sedona/spark/geopandas/base.py | Adds public GeoSeries/GeoDataFrame API docstrings and delegation hooks for build_area, polygonize, contains_properly, relate_pattern. |
| python/sedona/spark/geopandas/geoseries.py | Implements Spark execution for the four methods using Sedona ST functions and row-wise/aggregate patterns. |
| python/tests/geopandas/test_geoseries.py | Adds unit tests for build_area, polygonize, contains_properly, relate_pattern. |
| python/tests/geopandas/test_match_geopandas_series.py | Adds GeoPandas comparison tests for build_area, polygonize, contains_properly, relate_pattern. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Did you read the Contributor Guide?
Is this PR related to a ticket?
[GH-XXX] my subject. Closes Implement GeoSeries: relate_pattern, contains_properly, build_area, polygonize #2765What changes were proposed in this PR?
Implement 4 GeoSeries functions for the geopandas compatibility module.
Binary predicates:
relate_pattern(other, pattern, align)delegates toST_Relate(3-arg form returning boolean). Tests a DE-9IM pattern against the spatial relationship of two geometries.contains_properly(other, align)delegates toST_Relatewith DE-9IM patternT**FF*FF*. Sedona has noST_ContainsProperly, so this uses the equivalent DE-9IM matrix pattern.Aggregation methods:
build_area(node)delegates toST_Union_Aggr+ST_BuildArea. Aggregate operation matching geopandas semantics: all linework in the GeoSeries is combined, thenST_BuildAreabuilds polygons from the combined linework, and the result is exploded into individual polygons. Whennode=True(default), linework is noded viaST_Union_Aggr; whennode=False, it is collected viaST_Collect_Agg.polygonize(node, full)delegates toST_Union_Aggr+ST_Polygonize. Same aggregate pattern asbuild_area.full=TrueraisesNotImplementedError.Each function follows the established pattern from #2701, #2710, #2726, and #2732:
_delegate_to_geometry_columncallHow was this patch tested?
8 new tests (4 unit tests + 4 match tests) all passing locally.
Did this PR include necessary documentation updates?