Skip to content

[GH-3134] Implement distributed GeoPandas affine_transform - #3135

Merged
jiayuasu merged 2 commits into
apache:masterfrom
jiayuasu:feature/geopandas-affine-transform
Jul 22, 2026
Merged

[GH-3134] Implement distributed GeoPandas affine_transform#3135
jiayuasu merged 2 commits into
apache:masterfrom
jiayuasu:feature/geopandas-affine-transform

Conversation

@jiayuasu

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

  • Add GeoSeries.affine_transform(matrix) and GeoDataFrame geometry-column delegation.
  • Execute 2D and 3D affine transforms as distributed ST_Affine Spark expressions without driver collection or Python row UDFs.
  • Validate that matrices contain exactly 6 or 12 numeric coefficients, reject distributed/per-row inputs, and normalize valid coefficients to Python floats.
  • Map GeoPandas' 12-value coefficient order explicitly to Sedona's Python wrapper order.
  • Preserve index, CRS, SRID, nulls, typed empty geometries, and Z coordinates for 2D transforms.
  • Document JTS/Shapely differences for mixed-dimensional collections, M/ZM ordinates, and NaN Z values.
  • Add direct and GeoPandas parity coverage for 2D/3D transformations, geometry families, metadata, delegation, validation, and the coefficient-order regression.

How was this patch tested?

  • python -m pytest -p no:cacheprovider -q tests/geopandas/test_geoseries.py tests/geopandas/test_match_geopandas_series.py -k affine_transform — 10 passed.
  • Repository formatting, lint, security, and license hooks passed for all four changed files.

Did this PR include necessary documentation updates?

  • Yes. The new public API includes its coefficient layouts, equations, example, and engine-compatibility notes in the API docstring.

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 distributed GeoSeries.affine_transform(matrix) (and GeoDataFrame geometry-column delegation) by translating GeoPandas 2D/3D coefficient matrices into Sedona ST_Affine Spark expressions, with validation and parity tests to ensure correctness and metadata preservation.

Changes:

  • Added GeoSeries.affine_transform(matrix) with validation, float normalization, and explicit 3D coefficient reordering for Sedona’s ST_Affine wrapper signature.
  • Added GeoDataFrame/GeoSeries delegation entry and API docstring (including 2D/3D layouts and engine-difference notes).
  • Added direct and GeoPandas-parity tests covering 2D/3D behavior, coefficient order regression, metadata/SRID/CRS handling, and validation errors.

Reviewed changes

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

File Description
python/sedona/spark/geopandas/geoseries.py Implements GeoSeries.affine_transform using distributed ST_Affine with 2D/3D handling and validation.
python/sedona/spark/geopandas/base.py Adds delegated affine_transform API + docstring for GeoSeries/GeoDataFrame geometry-column delegation.
python/tests/geopandas/test_geoseries.py Adds unit tests for metadata/SRID/CRS preservation, dimension handling, coefficient ordering, and validation.
python/tests/geopandas/test_match_geopandas_series.py Adds GeoPandas parity tests for 2D parametrized matrices and a 3D case across geometry families.

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

Comment on lines +1178 to +1184
try:
matrix = tuple(matrix)
except (TypeError, ValueError) as exc:
raise TypeError("'matrix' must be a local ordered sequence") from exc

if len(matrix) not in (6, 12):
raise ValueError("'matrix' expects either 6 or 12 coefficients")
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Jul 22, 2026
@jiayuasu
jiayuasu marked this pull request as ready for review July 22, 2026 06:46
@jiayuasu
jiayuasu merged commit 33a8d7b into apache:master Jul 22, 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.

GeoPandas: implement distributed affine_transform

2 participants