Skip to content

GeoPandas: implement GeoJSON interface methods #3132

Closed as not planned
Closed as not planned

Description

@jiayuasu

Part of #2230.

Summary

Implement the closely related GeoJSON interface methods that are currently missing from Sedona's GeoPandas-compatible API:

  • GeoDataFrame.iterfeatures
  • GeoDataFrame.to_geo_dict
  • GeoDataFrame.__geo_interface__
  • GeoSeries.__geo_interface__

These methods should follow GeoPandas behavior while using Sedona's existing to_geopandas() materialization boundary. As with the current to_json, to_arrow, and plot implementations, this functionality will collect data to the driver and should be documented accordingly.

Requirements

  • Support iterfeatures(na="null", show_bbox=False, drop_id=False) argument semantics.
  • Return GeoPandas-compatible feature dictionaries, identifiers, bounding boxes, and null handling.
  • Keep to_geo_dict and both __geo_interface__ properties consistent with iterfeatures.
  • Preserve index values in feature identifiers unless drop_id=True.
  • Handle null geometries, empty geometries, mixed geometry types, and CRS-bearing inputs.
  • Add no new mandatory dependency.

Version compatibility

The Python 3.8 environment resolves GeoPandas 0.13.2, which does not provide GeoDataFrame.to_geo_dict. The implementation should supply a behavior-compatible fallback instead of skipping this API on Python 3.8. Newer environments should match their installed GeoPandas behavior.

Tests

Add direct and parity coverage for:

  • default, named, and non-string indexes;
  • drop_id=True and drop_id=False;
  • show_bbox=True and show_bbox=False;
  • na="null", na="drop", and na="keep";
  • null and empty geometries;
  • mixed geometry types;
  • CRS-bearing GeoDataFrames;
  • GeoDataFrame and GeoSeries __geo_interface__ output;
  • the GeoPandas 0.13.2 fallback path.

Likely files

  • python/sedona/spark/geopandas/geodataframe.py
  • python/sedona/spark/geopandas/geoseries.py
  • python/tests/geopandas/test_geodataframe.py
  • python/tests/geopandas/test_match_geopandas_dataframe.py
  • python/tests/geopandas/test_geoseries.py
  • python/tests/geopandas/test_match_geopandas_series.py

Acceptance criteria

  • All four APIs are implemented and documented.
  • Supported arguments and edge cases match GeoPandas behavior.
  • Python 3.8 with GeoPandas 0.13.2 remains supported.
  • Focused tests and the relevant Python matrix pass.
  • The implementation PR references Part of #2230 and does not close the epic.

Non-goals

  • A distributed or streaming GeoJSON iterator.
  • Changes to JVM or SQL geometry functions.
  • Implementing to_file, clip, overlay, or other unrelated GeoPandas APIs.

Activity

  1. jiayuasu commented on Jul 21, 2026

    @jiayuasu
    MemberAuthor

    Closing because these APIs return or iterate Python feature objects on the driver. Implementing them through to_geopandas() would collect the dataset and conflict with Sedona’s distributed-execution goals. We can revisit this only if a scalable distributed contract becomes available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions