我有一张约50,000行的表。每行都是一个多边形。我想比较所有行,看看哪些行正在接触/交叉。
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
并创建一个巨大的表格之外,比较每个多边形并返回它正在触摸/交叉的其他多边形的最佳方法是什么?
答案 0 :(得分:1)
只需加入交叉点
即可SELECT
a.PolygonID,
b.PolygonID
FROM
table1 AS a
INNER JOIN
table1 as b
ON (a.OGR_Geography.STIntersects(b.OGR_Geography) = 1);