I have a table with ~50,000 rows. Each row is a polygon. I would like to compare all the rows to see which ones are touching/intersect.
我有一个约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
Other than doing a CROSS JOIN
and creating a gigantic table, what would be the best way to compare each polygon and return which other polygon it is touching/intersect?
除了做一个CROSS JOIN并创建一个巨大的表之外,比较每个多边形并返回它正在接触/交叉的其他多边形的最佳方法是什么?
1 个解决方案
#1
1
Simply join on the Intersection
只需加入交叉路口即可
SELECT
a.PolygonID,
b.PolygonID
FROM
table1 AS a
INNER JOIN
table1 as b
ON (a.OGR_Geography.STIntersects(b.OGR_Geography) = 1);
#1
1
Simply join on the Intersection
只需加入交叉路口即可
SELECT
a.PolygonID,
b.PolygonID
FROM
table1 AS a
INNER JOIN
table1 as b
ON (a.OGR_Geography.STIntersects(b.OGR_Geography) = 1);