SQL:postgresql中合并多个geom数据ST_Union以及⽐较两个geom数据。。
合并:ST_Union
⽂档上是这样说的:
经过亲⾝实践,⽐较两个geom是很好⽤的,可是多个的时候,看⽹上说使⽤数组的形式 [geom1,geom2,geom3] ,可是并没有成功。。。于是只能反复合并两个,实现了合并多个。
代码:
合并两个
SELECT
ST_Union ((SELECT geom FROM department_info WHERE node_name ='陕西⼀队'),(SELECT geom
FROM department_info WHERE node_name ='陕西⼆队'))
合并多个
SELECT
ST_Union (
(SELECT ST_Union ((SELECT geom FROM department_info WHERE node_name ='陕西⼀队'),(SELECT geom FROM department_info WHERE nod e_name ='陕西⼆队'))),
(SELECT geom FROM department_info WHERE node_name ='陕西三队')
)
SELECT
ST_Union (
(
SELECT
ST_Union (
(
SELECT
sql中union多表合并
ST_Union (
(
SELECT
ST_Union (
(
SELECT
ST_Union (
(SELECT ST_Union ((SELECT geom FROM department_info WHERE id ='中⽯油西部管道乌鲁⽊齐输油⽓分公司'),(SELECT geom FROM department _info WHERE id ='中⽯油西部管道酒泉输油⽓分公司'))),
(SELECT geom FROM department_info WHERE id ='中⽯油西部管道⽢肃输油⽓分公司')
)
),
(SELECT geom FROM department_info WHERE id ='中⽯油西部管道塔⾥⽊输油⽓分公司')
)
),
(SELECT geom FROM department_info WHERE id ='中⽯油西部管道兰州输⽓分公司')
)
),
(SELECT geom FROM department_info WHERE id ='中⽯油西部管道新疆输油⽓分公司')
)
),
(SELECT geom FROM department_info WHERE id ='中⽯油西部管道独⼭⼦输油⽓分公司')
)
⽐较是否相同:ST_Equals
代码:
SELECT
ST_Equals (
(
SELECT
ST_Union (
(SELECT ST_Union ((SELECT geom FROM department_info WHERE node_name ='陕西⼀队'),(SELECT geom FROM department_info WHERE nod e_name ='陕西⼆队'))),
(SELECT geom FROM department_info WHERE node_name ='陕西三队')
)
),
(SELECT geom FROM department_info WHERE node_name ='陕西管理处')
)
结果:
SELECT
ST_Equals ((SELECT geom FROM department_info WHERE node_name ='陕西⼀队'),(SELECT geom FROM department_info WHERE node_name = '陕西⼀队'))

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。