gpt4 book ai didi

sql-server - 查找多边形重叠

转载 作者:行者123 更新时间:2023-12-04 02:10:48 24 4
gpt4 key购买 nike

我必须找到重叠的多边形并获取它们的几何形状。有人知道怎么做吗?

这是多边形表:

DECLARE @Table TABLE (
id varchar(32),
shape geometry);

INSERT INTO @Table VALUES
('California', geometry::Parse('POLYGON((-124.23 41.96, -119.97 41.93, -119.97 38.99, -113.95 34.30, -114.69 32.62, -117.11 32.43, -122.25 36.10, -124.23 41.96))')),
('Western US', geometry::Parse('POLYGON((-124.71 48.69, -102.97 48.86, -102.88 31.72, -117.15 32.39, -124.01 39.50, -124.71 48.69))')),
('US', geometry::Parse('POLYGON((-124.62 48.86, -94.57 48.98, -80.68 42.09, -66.88 45.02, -82.26 28.69, -98.96 26.90, -116.80 32.62, -124.36 39.77, -124.62 48.86))')),
('Colorado', geometry::Parse('POLYGON((-108.98 40.91, -108.98 36.87, -101.95 36.87, -101.95 40.91, -108.98 40.91))'));

最佳答案

这行得通吗?

SELECT
T.id
, O.id
, T.shape.STIntersection(O.shape) Intersection
FROM @Table T
INNER JOIN @Table O
ON T.shape.STIntersects(T.shape) = 1
AND T.id > O.id

关于sql-server - 查找多边形重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10079879/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com