跳转至
🎉 SedonaDB 0.4.0 已正式发布!🗺️ 新增 Python DataFrame API、R dplyr 接口、Geography 支持及 GPU 加速空间连接。阅读发布博客 →

ST_Intersection

Introduction: Returns the closed-set spherical intersection of two Geography values. Edges are interpreted as great-circle arcs, and the result can be passed directly to Geography functions such as ST_Area for measurements in square meters.

Format:

ST_Intersection(A: Geography, B: Geography)

Return type: Geography

Since: v1.9.1

Both inputs must be Geography values. Boundary-only intersections are retained: crossing lines or touching polygon vertices can produce a Point, while shared polygon edges can produce a LineString. Results containing several dimensions are returned as a GeometryCollection.

Polygon ring roles follow the simple-features structure: the first ring is a shell and subsequent rings are holes, regardless of input winding. Each shell is normalized to an area of at most one hemisphere. A shell intended to represent more than half the sphere is therefore interpreted as its complement; reversing the ring's coordinate sequence does not select the larger region.

The result is two-dimensional and copies the first input's SRID without transforming either input or validating that their SRIDs match. An explicitly empty operand produces GEOMETRYCOLLECTION EMPTY. A disjoint result from two non-empty inputs preserves the lower input dimension, such as LINESTRING EMPTY for two disjoint lines.

SQL Example

WITH overlap AS (
  SELECT ST_Intersection(
    ST_GeogFromWKT('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))', 4326),
    ST_GeogFromWKT('POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))', 4326)
  ) AS geog
)
SELECT ST_GeometryType(geog), ST_Area(geog)
FROM overlap;

Output:

ST_Polygon | 3.071055126726233E11