空间 SQL 比较 table 和 return 中的所有多边形哪些相交

Spatial SQL Compare all polygons in table and return which ones intersect

我有一个 table 约 50,000 行。每行都是一个多边形。我想比较所有行以查看哪些是 touching/intersect.

Select a.PolygonID, b.PolygonID, a.OGR_Geography.STIntersects(b.OGR_Geography) as Intersect
into #temp1
FROM table1 as a cross join table1 as b;

Select a.PolygonID, b.PolygonID,Intersect
WHERE Intersection = 1 

除了做一个 CROSS JOIN 并创建一个巨大的 table 之外,比较每个多边形和 return 它是哪个其他多边形的最佳方法是什么 touching/intersect ?

只需在十字路口加入

SELECT
    a.PolygonID,
    b.PolygonID
FROM
    table1 AS a
    INNER JOIN
    table1 as b
    ON (a.OGR_Geography.STIntersects(b.OGR_Geography) = 1);