简体   繁体   English

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

[英]how to find percentage or area of overlapped area of a polygon

In SQL Server 2008 R2 I have created some polygons. 在SQL Server 2008 R2中,我创建了一些多边形。 I have also selected which polygon is overlapping another one Now I want to know overlapped area or percentage. 我还选择了哪个多边形与另一个多边形重叠现在,我想知道重叠的面积或百分比。

For area I am trying following SQL 对于区域,我正在尝试遵循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') ;

in above SQL 在上面的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';

is running fine but when I add STArea() function it results an error 运行正常,但是当我添加STArea()函数时会导致错误

Msg 102, Level 15, State 1, Line 11 Msg 102,第15级,状态1,第11行
Incorrect syntax near ';'. ';'附近的语法不正确。

You need an Alias for your subquery say A and also to your functions specially in your inner query for example: 您需要为子查询说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 ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM