PostGIS函数将几何线连接在一起? [英] PostGIS function to connect geometry LINE together?
问题描述
(注意:the_geom是一个几何值(类型:LINESTRING),在这种情况下,我随机选择它们以供读取)
gid | kstart |肯德| 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
<实践描述]对于那些不介意这个目的的人来说,可以跳过这个
我想做'this'(来自我过去的问题的一组查询,链接
位于这篇文章的末尾)表B中的每一行(又名
land_inventory)。这两个表格通过'ctrl_sec_no'
(也就是道路的控制部分号码)相关,这意味着::在一个
ctrl_sec_no - 120802(实际上,这是一条相当于3
几何LINESTRINGs(the_geom)连接在一起,从kstart 238(从238公里开始)到kend 250)
[ PostGIS问题]
问题是如何将这3行{aka gid(626,638,4037)从表}连接在一起并导致'the_sum_geom'(最初为NULL)通过使用PostGIS功能(无论)。之后我们将使用这个'the_sum_geom'来找到这个几何体上的POINT LINESTRING
( 您正在寻找的功能是 使用 ST_LineMerge 你可以从Multiline转换为LineString,但是有一个警告,如果多行不能合并,它将返回多行而不做任何修改。请参阅 ST_LineMerge 文档,以了解ST_LineMerge可以或不可以执行的操作。 (note: the_geom is a geometry value (TYPE: LINESTRING), in this case i random them for readability) [Real Practice Description] just skip this for those who don't mind the purpose 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 question] the question is how to connect this 3 lines {aka gid(626,638,4037) from the table} together and result in 'the_sum_geom' (initially NULL) by using PostGIS functions (whatever). after that we will use this 'the_sum_geom' to find the POINT on this geometry LINESTRING (How calculate things from many tables by using a few queries?). The function you are looking for is ST_Union, you need to use it with the aggregate form: With ST_LineMerge you can convert from Multiline to LineString but there is a caveat, if the multi line cant be merged it will return the multiline without any modification. See the ST_LineMerge docs to understand what ST_LineMerge can or can't do. 这篇关于PostGIS函数将几何线连接在一起?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
,您需要使用它: the_sum_geom = 更新mytable集合rel =nofollow> ST_Union
ST_LineMerge((从mytable中选择ST_Union(the_geom),其中ctrl_sec_no = 120802))
其中ctrl_sec_no = 120802;
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
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;