sde用sql实现erase_MySQL
本文讲述基于Arc SDE forOracle实现erase空间分析计算。
实现流程:
1、叠加计算
判断叠加,非叠加部分即为一部分所要结果,叠加部分进入第二步;
2、合并计算
根据objectid进行union计算;
3、差异计算
用原始数据data1和合并计算后的结果进行差异计算,所得的结果即为另一部分所要结果。
相关sde函数介绍:
1、sde.st_intersection(st_geometryshape1, st_geometry shape2)
语法:
参数:(st_geometry shape1, st_geometryshape2)
返回值:st_geometry shape
解释:
Returns a geometry that represents the shared portion of shape1 andshape2.
示意:
2、sde.st_union(st_geometryshape1, st_geometry shape2)
语法:
参数:(st_geometry shape1, st_geometryshape2)
返回值:st_geometry shape
解释:
Returns a geometry that represents the point set union of theGeometries.
示意:
3、sde.st_difference(st_geometryshape1, st_geometry shape2)
语法:
参数:(st_geometry shape1, st_geometryshape2)
返回值:st_geometry shape
解释:
Returns a geometry thatrepresents that part of geometry A that does not intersect with geometry B.
示意:
说明:
看到图3,很多人就开始问了:erase的效果不就是图3的效果吗,为什么还要那么多步?是的,对于两两的geometry来说,difference结果即为我们想要的erase的结果,但是,对于两个图层来说,difference后的结果是整个data2的结果,并且结果中会有一些叠加与重复。为什么会出现这样的结果呢,我想sde的算法实现中,也是两两做的计算,因此,计算的结果就是整个data2的结果。举例:A为data1的一个要素,B、C分别为data2的两个要素,在sde中,difference计算的结果为图4,1和2分别为计算后的结果,并重叠在一起显示,但是实际中,我们想要的及全国是图5。
图4
图5
实现sql实例:
1、计算叠加
insert intohx2q_risk_result_temp(objid,shape) select * from (select a.objectid,sde.st_intersection(a.shape, b.shape) as shape from hx2q_project a, hx2q_landnormb where a.ptcode = 'm01' and b.ptcode = 'm01' and a.status = '开工' and b.confirm = '已取得' and a.flag = 0 and b.flag = 0) where sde.st_area(shape) > 0
2、计算union
3、计算difference
insert intoHX2Q_RISK_RESULT (objid, ptcode, Shape, objectid) select a.objectid, a.ptcode, sde.st_difference(a.shape, b.shape) asshape, SDE.version_user_ddl.NEXT_ROW_ID('HX2Q','36') as objectid from hx2q_project a, hx2q_risk_result_temp b where a.objectid = b.objid
4、获取非叠加
insert intoHX2Q_RISK_RESULT (objid, ptcode, Shape, objectid) select objectid, ptcode, shape, SDE.version_user_ddl.NEXT_ROW_ID('HX2Q','36') from hx2q_project where objectid not in (select distinct objidfrom hx2q_risk_result_temp) and ptcode = 'm01' and flag = 0 and status = '开工'
说明:
1、difference计算中,where后的条件是必须的;
2、union计算是通过后台程序实现的。
以上就是sde用sql实现erase_MySQL的内容,更多相关内容请关注PHP中文网(www.php.cn)!