(注意:the_geom是一个几何值(TYPE: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)从表}连接在一起,并通过使用PostGIS函数(无论如何)导致’the_sum_geom'(最初为NULL).之后我们将使用这个’the_sum_geom’在这个几何LINESTRING上找到POINT
(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可以或不可以执行的操作.