(注意:the_geom 是一个几何值(类型:LINESTRING),在这种情况下,我将它们随机化以提高可读性)
gid | kstart | kend | ctrl_sec_no | the_geom | the_sum_geom
626 | 238 | 239 | 120802 | 123456 | NULL
638 | 249 | 250 | 120802 | 234567 | NULL
4037| 239 | 249 | 120802 | 345678 | NULL
【实战说明】不介意者略过
I would like to do 'this' (a set of queries from my past question, link located on the end of this post) for every row in Table B (aka. land_inventory). These two tables are related by 'ctrl_sec_no' (aka. control section number of a road) which means :: in ONE ctrl_sec_no -- 120802 (in fact, it is a road which is equivalent to 3 geometry LINESTRINGs (the_geom) connected together, from kstart 238 (start at kilometre of 238) to kend 250)
[PostGIS 问题]
问题是如何将这 3 行 {aka gid(626,638,4037) from the table} 连接在一起,并通过使用 PostGIS 函数(无论如何)产生“the_sum_geom”(最初为 NULL)。之后我们将使用这个 'the_sum_geom' 找到这个几何 LINESTRING 上的点
(How calculate things from many tables by using a few queries?)。
最佳答案
您要找的函数是ST_Union ,您需要将其与聚合形式一起使用:
update mytable set the_sum_geom =
ST_LineMerge( ( select ST_Union(the_geom) from mytable where ctrl_sec_no = 120802 ) )
where ctrl_sec_no = 120802;
与 ST_LineMerge您可以从 Multiline 转换为 LineString 但有一个警告,如果不能合并多行,它将返回多行而不进行任何修改。查看ST_LineMerge文档以了解 ST_LineMerge 可以做什么或不能做什么。
关于php - 将几何线连接在一起的 PostGIS 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9213026/