Skip to content

GeoPandas: preserve authoritative no-CRS metadata for local geometry columns #3271

Closed

Description

@jiayuasu

Problem

Sedona's distributed GeoPandas layer uses field metadata to distinguish a known CRS from a geometry column whose CRS must be inferred from its embedded SRID. A locally constructed geometry column with crs=None currently has no CRS metadata, so it is indistinguishable from a raw distributed geometry column with unknown provenance.

Reading .crs for such a metadata-free column performs a distributed ST_SRID(first(...)) aggregation. APIs that inspect both operands' CRS, including binary geometry predicates, can therefore launch two eager Spark actions before returning an otherwise lazy result.

In a local Spark benchmark, comparing two CRS-less local operands submitted four Spark jobs before result materialization. Recording authoritative no-CRS metadata reduced that count to zero. The one-time constructor cost increased by approximately 2.3 ms for GeoSeries and 4.9 ms for GeoDataFrame in a warm one-row benchmark.

Expected behavior

Sedona should represent three distinct states:

  1. a known CRS stored as CRS metadata;
  2. a known absence of CRS stored as explicit empty CRS metadata; and
  3. an unknown raw or legacy distributed geometry column with no CRS metadata, which retains the existing embedded-SRID fallback.

The implementation should:

  • record explicit no-CRS metadata for locally owned GeoSeries and GeoDataFrame geometry columns;
  • preserve locally supplied per-column CRS values and synchronize their embedded SRIDs;
  • propagate authoritative CRS state through set_geometry, WKT/WKB and file constructors, copies, selections, and all-null geometry columns;
  • preserve public crs=None without erasing an embedded EWKB SRID;
  • leave raw Spark and pandas-on-Spark geometry columns without metadata on the existing SRID-inference path;
  • preserve Series names, indexes, active-geometry selection, and laziness; and
  • add action-count, metadata propagation, raw-column fallback, and compatibility coverage across supported Spark and GeoPandas versions.

Performance acceptance

  • Constructing a binary predicate result from two locally created CRS-less operands should launch no Spark jobs solely for CRS discovery.
  • Metadata-free raw distributed operands should continue to infer their embedded SRIDs and warn when they differ.
  • The returned predicate and geometry plans should remain distributed and should not add Python execution nodes.

Part of #2230.

Sedona version

2.0.0-SNAPSHOT

API type

Python / distributed GeoPandas API

Activity

  1. minhpham1810 commented on Aug 23, 2026

    @minhpham1810
    Contributor

    I'd like to work on this. Root cause looks to be GeoSeries.__init__ only calling set_crs when crs is not None, so locally-constructed columns never get authoritative "no CRS" metadata written (the tri-state scheme from #3190 already supports it, just isn't wired up for the crs=None case). Planning to fix the constructor path plus from_wkt/from_wkb/set_geometry, and add job-count regression tests per the acceptance criteria above.

  2. jiayuasu commented on Aug 24, 2026

    @jiayuasu
    MemberAuthor

    @minhpham1810 Sounds good. Your direction looks right, and #3190 provides the tri-state foundation. Please make sure authoritative crs=None is attached metadata-only rather than through set_crs(None), preserve per-column and inherited CRS behavior in GeoDataFrame/set_geometry, leave metadata-free distributed columns on SRID inference, include file constructors, and add actual Spark job-count and no-Python-plan tests.

  3. minhpham1810 commented on Aug 24, 2026

    @minhpham1810
    Contributor

    @minhpham1810 Sounds good. Your direction looks right, and #3190 provides the tri-state foundation. Please make sure authoritative crs=None is attached metadata-only rather than through set_crs(None), preserve per-column and inherited CRS behavior in GeoDataFrame/set_geometry, leave metadata-free distributed columns on SRID inference, include file constructors, and add actual Spark job-count and no-Python-plan tests.

    Thanks. I'll put up a PR soon.

  4. added 3 commits that reference this issue on Aug 26, 2026
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