You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2026/10/20 07:25:20 UTC

(sedona) branch master updated: [GH-3495] Fix the GeoPandas API buffer docs, read_file warning and from_wkt/from_wkb arguments (#3496)

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

jiayuasu 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 af2ef373343 [GH-3495] Fix the GeoPandas API buffer docs, read_file warning and from_wkt/from_wkb arguments (#3496)
af2ef373343 is described below

commit af2ef37334319841a8dc3f5761b623183c574ef3
Author: Jia Yu <ji...@apache.org>
AuthorDate: Tue Oct 20 00:25:13 2026 -0700

    [GH-3495] Fix the GeoPandas API buffer docs, read_file warning and from_wkt/from_wkb arguments (#3496)
---
 python/sedona/spark/geopandas/base.py                |  5 +++--
 python/sedona/spark/geopandas/geoseries.py           | 20 ++++++++++++++------
 python/sedona/spark/geopandas/io.py                  | 13 +++++++------
 python/tests/geopandas/test_geoseries.py             | 15 +++++++++++++++
 python/tests/geopandas/test_io.py                    | 15 +++++++++++++++
 .../tests/geopandas/test_match_geopandas_series.py   |  5 +++++
 6 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/python/sedona/spark/geopandas/base.py b/python/sedona/spark/geopandas/base.py
index 6fd2227c029..f030951df64 100644
--- a/python/sedona/spark/geopandas/base.py
+++ b/python/sedona/spark/geopandas/base.py
@@ -5141,8 +5141,9 @@ class GeoFrame(metaclass=ABCMeta):
         mitre_limit : float, default 5.0
             The mitre limit ratio for joins when join_style='mitre'.
         single_sided : bool, default False
-            Whether to create a single-sided buffer. In Sedona, True will default to left-sided buffer.
-            However, 'right' may be specified to use a right-sided buffer.
+            Whether to create a single-sided buffer. As in GeoPandas, the sign of
+            ``distance`` picks the side: a positive distance buffers the left side,
+            and a negative distance buffers the right side.
         **kwargs
             Accepted for compatibility with GeoPandas and ignored.
 
diff --git a/python/sedona/spark/geopandas/geoseries.py b/python/sedona/spark/geopandas/geoseries.py
index 4f3dd26a3df..b2a3d04bca6 100644
--- a/python/sedona/spark/geopandas/geoseries.py
+++ b/python/sedona/spark/geopandas/geoseries.py
@@ -4478,9 +4478,9 @@ class GeoSeries(GeoFrame, pspd.Series):
               unclosed rings). If this is not possible, they are returned as ``None``
               without a warning. Requires GEOS >= 3.11 and shapely >= 2.1.
 
-        kwargs
-            Additional arguments passed to the Series constructor,
-            e.g. ``name``.
+        **kwargs
+            Only ``name`` is supported, the name of the resulting GeoSeries.
+            Other keyword arguments raise ``TypeError``.
 
         Returns
         -------
@@ -4514,6 +4514,10 @@ class GeoSeries(GeoFrame, pspd.Series):
         2    POINT (3 3)
         dtype: geometry
         """
+        unsupported = set(kwargs) - {"name"}
+        if unsupported:
+            arguments = ", ".join(sorted(unsupported))
+            raise TypeError(f"Unsupported GeoSeries.from_wkb arguments: {arguments}")
         if on_invalid != "raise":
             raise NotImplementedError(
                 "GeoSeries.from_wkb(): only on_invalid='raise' is implemented"
@@ -4566,9 +4570,9 @@ class GeoSeries(GeoFrame, pspd.Series):
               unclosed rings). If this is not possible, they are returned as ``None``
               without a warning. Requires GEOS >= 3.11 and shapely >= 2.1.
 
-        kwargs
-            Additional arguments passed to the Series constructor,
-            e.g. ``name``.
+        **kwargs
+            Only ``name`` is supported, the name of the resulting GeoSeries.
+            Other keyword arguments raise ``TypeError``.
 
         Returns
         -------
@@ -4594,6 +4598,10 @@ class GeoSeries(GeoFrame, pspd.Series):
         2    POINT (3 3)
         dtype: geometry
         """
+        unsupported = set(kwargs) - {"name"}
+        if unsupported:
+            arguments = ", ".join(sorted(unsupported))
+            raise TypeError(f"Unsupported GeoSeries.from_wkt arguments: {arguments}")
         if on_invalid != "raise":
             raise NotImplementedError(
                 "GeoSeries.from_wkt(): only on_invalid='raise' is implemented"
diff --git a/python/sedona/spark/geopandas/io.py b/python/sedona/spark/geopandas/io.py
index c31b4e1d034..7bf2744fea6 100644
--- a/python/sedona/spark/geopandas/io.py
+++ b/python/sedona/spark/geopandas/io.py
@@ -254,9 +254,9 @@ def read_file(filename: str, format: Union[str, None] = None, **kwargs):
             - "geoparquet"
     **kwargs
         Reader options. Only ``table_name`` is used: the name of the table to
-        read, required when ``format`` is "geopackage". Sedona warns about the
-        keyword arguments it receives, since other GeoPandas reader options are
-        not supported.
+        read, required when ``format`` is "geopackage". Sedona warns about any
+        other keyword argument, since other GeoPandas reader options are not
+        supported.
 
     See also
     --------
@@ -264,8 +264,9 @@ def read_file(filename: str, format: Union[str, None] = None, **kwargs):
     """
 
     # We warn the user if they try to use arguments that GeoPandas supports but not Sedona.
-    if kwargs:
-        warnings.warn(f"The given arguments are not supported in Sedona: {kwargs}")
+    unsupported = {k: v for k, v in kwargs.items() if k != "table_name"}
+    if unsupported:
+        warnings.warn(f"The given arguments are not supported in Sedona: {unsupported}")
 
     spark = default_session()
 
@@ -392,4 +393,4 @@ def read_parquet(
     if kwargs:
         warnings.warn(f"The given arguments are not supported in Sedona: {kwargs}")
 
-    return read_file(path, format="geoparquet", **kwargs)
+    return read_file(path, format="geoparquet")
diff --git a/python/tests/geopandas/test_geoseries.py b/python/tests/geopandas/test_geoseries.py
index b7572eaeefd..8141b4553cb 100644
--- a/python/tests/geopandas/test_geoseries.py
+++ b/python/tests/geopandas/test_geoseries.py
@@ -1008,6 +1008,21 @@ class TestGeoSeries(TestGeopandasBase):
         expected = gpd.GeoSeries([Point(1, 1), Point(2, 2), Point(3, 3)])
         self.check_sgpd_equals_gpd(s, expected)
 
+    @pytest.mark.parametrize(
+        "constructor,value",
+        [
+            (GeoSeries.from_wkt, "POINT (1 1)"),
+            (GeoSeries.from_wkb, Point(1, 1).wkb),
+        ],
+        ids=["wkt", "wkb"],
+    )
+    def test_wkt_wkb_keyword_arguments(self, constructor, value):
+        assert constructor([value], name="geom").name == "geom"
+        with pytest.raises(
+            TypeError, match="Unsupported GeoSeries.from_wk[tb] arguments: dtype"
+        ):
+            constructor([value], dtype="geometry")
+
     @pytest.mark.parametrize(
         "constructor,value",
         [
diff --git a/python/tests/geopandas/test_io.py b/python/tests/geopandas/test_io.py
index ae24b1ffe7c..387722afe68 100644
--- a/python/tests/geopandas/test_io.py
+++ b/python/tests/geopandas/test_io.py
@@ -20,6 +20,7 @@ import json
 import os
 import sqlite3
 import tempfile
+import warnings
 import pytest
 import shapely
 import pandas as pd
@@ -359,6 +360,20 @@ class TestIO(TestGeopandasBase):
         assert df.active_geometry_name == "geom"
         assert df["geom"].count() == expected_cnt
 
+    def test_read_file_warns_only_about_unsupported_arguments(self):
+        datafile = os.path.join(TEST_DATA_DIR, "geopackage/features.gpkg")
+        table_name = "GB_Hex_5km_GS_Landslides_v8"
+
+        with warnings.catch_warnings(record=True) as caught:
+            warnings.simplefilter("always")
+            read_file(datafile, table_name=table_name)
+        assert not [w for w in caught if "not supported in Sedona" in str(w.message)]
+
+        with pytest.warns(UserWarning, match="not supported in Sedona") as caught:
+            read_file(datafile, table_name=table_name, rows=10)
+        messages = [str(w.message) for w in caught]
+        assert any("rows" in m and "table_name" not in m for m in messages)
+
     def test_geoseries_from_geopackage_uses_source_geometry_name(self):
         datafile = os.path.join(TEST_DATA_DIR, "geopackage/features.gpkg")
 
diff --git a/python/tests/geopandas/test_match_geopandas_series.py b/python/tests/geopandas/test_match_geopandas_series.py
index ece028d86f2..014cb0da8ae 100644
--- a/python/tests/geopandas/test_match_geopandas_series.py
+++ b/python/tests/geopandas/test_match_geopandas_series.py
@@ -260,6 +260,11 @@ class TestMatchGeopandasSeries(TestGeopandasBase):
         gpd_result = gpd.GeoSeries(self.linestrings).buffer(0.2, single_sided=True)
         self.check_sgpd_equals_gpd(sgpd_result, gpd_result)
 
+        # A negative distance buffers the right side.
+        sgpd_result = GeoSeries(self.linestrings).buffer(-0.2, single_sided=True)
+        gpd_result = gpd.GeoSeries(self.linestrings).buffer(-0.2, single_sided=True)
+        self.check_sgpd_equals_gpd(sgpd_result, gpd_result)
+
         sgpd_result = GeoSeries(self.linestrings).buffer(
             0.2, join_style="mitre", mitre_limit=10.0
         )