如何找到多边形重叠区域的百分比或面积

时间:2013-11-07 06:11:42

标签: sql sql-server sql-server-2008-r2 spatial

在SQL Server 2008 R2中,我创建了一些多边形。我还选择了哪个多边形与另一个多边形重叠现在我想知道重叠区域或百分比。

对于我正在尝试关注SQL的区域

SELECT location.STArea()
FROM
  ( SELECT location.STIntersection(
           (SELECT LOCATION
            FROM TEST.dbo.cn_overlap_trn
            WHERE plot_no = '657065700016801' ) )
   FROM TEST.dbo.cn_overlap_trn
   WHERE plot_no ='657065700016701') ;
上面SQL中的

SELECT location.STIntersection(
       (SELECT LOCATION
        FROM TEST.dbo.cn_overlap_trn
        WHERE plot_no = '657065700016801' ) )
FROM TEST.dbo.cn_overlap_trn
WHERE plot_no ='657065700016701';

运行正常但是当我添加STArea()函数时会导致错误

  

Msg 102,Level 15,State 1,Line 11
  ';'附近的语法不正确。

1 个答案:

答案 0 :(得分:0)

您的子查询需要一个别名A,还需要特别在内部查询中的函数,例如:

Select location.STArea() as Area from
(
    select 
    location.STIntersection(
        ( 
        select location from TEST.dbo.cn_overlap_trn where plot_no =  '657065700016801'
        )
                            ) as Intersection
    from TEST.dbo.cn_overlap_trn 
    where plot_no ='657065700016701'
) A ;