Skip to content

Add ST_Split #823

Description

@yharby

ST_Split (split a geometry by a blade geometry, returning the pieces as a GEOMETRYCOLLECTION) is a common PostGIS function missing from duckdb-spatial.

Important, the bundled GEOS is 3.14.1, and native GEOSSplit only landed in GEOS 3.15, so a native bind is not linkable today. The PostGIS recipe composes the result entirely from primitives duckdb-spatial already ships, so it works on 3.14.1 now, and a native GEOSSplit bind can replace it later behind a version guard once the vcpkg baseline reaches 3.15.

Polygon by line recipe (mirrors PostGIS lwgeom_split in lwgeom_geos_split.c)

flowchart TD
    A[target polygon] --> B[ST_Boundary]
    C[blade line] --> D[ST_Union of boundary and blade]
    B --> D
    D --> E[ST_Polygonize rebuild faces]
    E --> F[keep faces whose point on surface lies inside the original]
    F --> G[GEOMETRYCOLLECTION of pieces]
Loading

Line by point or line recipe, ST_Node of the union then collect the parts, or ST_Difference for simple cases.

Implementer tips

  • Every primitive above already exists as a registered function and a GeosGeometry wrapper (ST_Boundary, ST_Union, ST_Polygonize, ST_PointOnSurface, ST_Contains, ST_Difference, ST_Node), so a composed ST_Split chains existing wrappers in one Execute with no new GEOS calls.
  • Return a GEOMETRYCOLLECTION of the pieces, matching PostGIS.
  • Path B, a thin GEOSSplit_r bind behind #if (GEOS_VERSION_MAJOR > 3) || (GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR >= 15), switched on when the baseline advances.

This is adjacent to the ST_Subdivide work in #719 and #583. Both partition geometries, though split by a blade is distinct, so a shared note on scope may help.

Sharing this as research in case it helps whoever picks it up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions