This is an automated email from the ASF dual-hosted git repository.

jiayu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sedona.git


The following commit(s) were added to refs/heads/master by this push:
     new acb9c0594e [GH-2266] Geopandas: Remove unnecessary old_crs check and 
in `to_crs` (#2267)
acb9c0594e is described below

commit acb9c0594ec6725ebd2fd90e7762bd297d4a49e5
Author: Peter Nguyen <[email protected]>
AuthorDate: Mon Aug 11 16:43:00 2025 -0700

    [GH-2266] Geopandas: Remove unnecessary old_crs check and in `to_crs` 
(#2267)
    
    * Remove unnecessary old_crs check and in to_crs
    
    * Add missing keep_names=True to to_crs
    
    * Call _to_pandas() instead of to_pandas() to quiet extra warning
---
 python/sedona/spark/geopandas/geodataframe.py |  2 +-
 python/sedona/spark/geopandas/geoseries.py    | 14 +-------------
 python/tests/geopandas/test_geoseries.py      |  5 ++++-
 3 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/python/sedona/spark/geopandas/geodataframe.py 
b/python/sedona/spark/geopandas/geodataframe.py
index 466f59406f..2470f310a0 100644
--- a/python/sedona/spark/geopandas/geodataframe.py
+++ b/python/sedona/spark/geopandas/geodataframe.py
@@ -775,7 +775,7 @@ class GeoDataFrame(GeoFrame, pspd.DataFrame):
                 # Use _to_geopandas instead of to_geopandas to avoid logging 
extra warnings
                 pd_df[col_name] = series._to_geopandas()
             else:
-                pd_df[col_name] = series.to_pandas()
+                pd_df[col_name] = series._to_pandas()
 
         return gpd.GeoDataFrame(pd_df, geometry=self._geometry_column_name)
 
diff --git a/python/sedona/spark/geopandas/geoseries.py 
b/python/sedona/spark/geopandas/geoseries.py
index 62004adf63..ff3a5cb9dc 100644
--- a/python/sedona/spark/geopandas/geoseries.py
+++ b/python/sedona/spark/geopandas/geoseries.py
@@ -2351,14 +2351,6 @@ class GeoSeries(GeoFrame, pspd.Series):
 
         from pyproj import CRS
 
-        old_crs = self.crs
-        if old_crs is None:
-            raise ValueError(
-                "Cannot transform naive geometries.  "
-                "Please set a crs on the object first."
-            )
-        assert isinstance(old_crs, CRS)
-
         if crs is not None:
             crs = CRS.from_user_input(crs)
         elif epsg is not None:
@@ -2366,17 +2358,13 @@ class GeoSeries(GeoFrame, pspd.Series):
         else:
             raise ValueError("Must pass either crs or epsg.")
 
-        # skip if the input CRS and output CRS are the exact same
-        if old_crs.is_exact_same(crs):
-            return self
-
         spark_expr = stf.ST_Transform(
             self.spark.column,
-            F.lit(f"EPSG:{old_crs.to_epsg()}"),
             F.lit(f"EPSG:{crs.to_epsg()}"),
         )
         return self._query_geometry_column(
             spark_expr,
+            keep_name=True,
         )
 
     @property
diff --git a/python/tests/geopandas/test_geoseries.py 
b/python/tests/geopandas/test_geoseries.py
index 8c6c8974ac..7365bdcdc9 100644
--- a/python/tests/geopandas/test_geoseries.py
+++ b/python/tests/geopandas/test_geoseries.py
@@ -405,7 +405,9 @@ class TestGeoSeries(TestGeopandasBase):
     def test_to_crs(self):
         from pyproj import CRS
 
-        geoseries = sgpd.GeoSeries([Point(1, 1), Point(2, 2), Point(3, 3)], 
crs=4326)
+        geoseries = sgpd.GeoSeries(
+            [Point(1, 1), Point(2, 2), Point(3, 3)], crs=4326, name="geometry"
+        )
         assert isinstance(geoseries.crs, CRS) and geoseries.crs.to_epsg() == 
4326
         result = geoseries.to_crs(3857)
         assert isinstance(result.crs, CRS) and result.crs.to_epsg() == 3857
@@ -416,6 +418,7 @@ class TestGeoSeries(TestGeopandasBase):
                 Point(333958.4723798207, 334111.1714019597),
             ],
             crs=3857,
+            name="geometry",
         )
         self.check_sgpd_equals_gpd(result, expected)
 

Reply via email to