简体   繁体   English

删除多边形外部的几何数据

[英]Remove Geometry data that is outside of a polygon

I am creating a SQL Server table that takes data from a OS MasterMap layer if it sits within the SITES_TEST layer. 我正在创建一个SQL Server表,如果该表位于SITES_TEST层内,则该表将从OS MasterMap层获取数据。

First I am using STIntersects to get the OS MM data into an ASSETS layer. 首先,我正在使用STIntersects将OS MM数据放入ASSETS层。

INSERT INTO ASSETS(GEOMETRY, THEMES) 
    (select b.GEOMETRY, b.THEMES from 
          SITES_TEST a,
          MM_TOPO b
          where a.geometry.STBuffer(1).STIntersects(b.geometry) = 1 AND  (b.THEMES ='Land' or b.THEMES ='Roads Tracks And Paths')) 

The Blue boundary is my site layer and in the background OS MasterMap. 蓝色边界是我的站点层,位于后台OS MasterMap中。 蓝色边界是我的网站层

After the query above is run in SQL Server it returns the overlapping data as well as the contained data. 在SQL Server中运行上述查询后,它会返回重叠数据以及所包含的数据。 I get that I could use STContains but then that leaves out data that goes both within and outside the boundary. 我知道我可以使用STContains,但是这样就忽略了边界内外的数据。

在此处输入图片说明

I was hoping I would be able to run an UPDATE on the ASSETS table using STDifference. 我希望我可以使用STDifference在ASSETS表上运行UPDATE。

UPDATE ASSETS(GEOMETRY) 
        (select b.GEOMETRY from 
              SITES_TEST a,
              MM_TOPO b
              where a.geometry.STDifference(b.geometry)=1) 

But I think I am going about it the wrong way as this is returning a boolean error. 但是我认为我正在以错误的方式进行处理,因为这将返回布尔错误。

Invalid operator for data type. 数据类型的运算符无效。 Operator equals equal to, type equals geometry. 运算符等于,类型等于几何。

Summary: I am trying to remove geometry that is outside of another geometry. 摘要:我正在尝试删除另一个几何之外的几何。 The first picture shows a blue polygon, then the SQL script is run which results in the second picture which shows data in red that sits outside the blue boundary polygon from the first picture. 第一张图片显示一个蓝色多边形,然后运行SQL脚本,导致第二张图片显示红色数据,该数据位于第一张图片的蓝色边界多边形之外。 I want to remove the data that is now outside the blue polygon. 我想删除蓝色多边形外的数据。

Instead of just asking for geometries that intersect the polygon of interest, which returns all of the intersecting geometry (as you found out) you want just the parts of the geometry that intersect your polygon of interest. 而不是仅仅要求该几何intersect感兴趣的多边形,它返回所有的相交的几何形状(如你发现了),你只想要相交的几何形状的零件您感兴趣的多边形。 So something like: 所以像这样:

INSERT INTO ASSETS(GEOMETRY, THEMES) 
    (select b.GEOMETRY.STIntersection(a.geometry, b.THEMES from 
          SITES_TEST a,
          MM_TOPO b
          where a.geometry.STBuffer(1).STIntersects(b.geometry) = 1 AND  (b.THEMES ='Land' or b.THEMES ='Roads Tracks And Paths')) 

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

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