PostGIS函数将几何线连接在一起?

发布于 2025-01-04 00:37:34 字数 912 浏览 4 评论 0原文

(注意: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

[真实实践描述] 对于那些不介意目的的人,请跳过此部分

我想做“这个”(我过去的问题中的一组查询,链接 位于本文末尾)对于表 B 中的每一行(又名。 土地库存)。这两个表通过“ctrl_sec_no”相关 (又名道路的控制路段编号),这意味着 :: 在 ONE 中 ctrl_sec_no -- 120802(实际上是一条路,相当于3 连接在一起的几何线串 (the_geom),从 kstart 238(从 238 公里开始)到 kend 250)

[PostGIS问题]

问题是如何将这3条线{aka gid(626,638,4037)从表中连接在一起并得到结果通过使用 PostGIS 函数(无论如何)在“the_sum_geom”(最初为 NULL)中。之后,我们将使用这个“the_sum_geom”来查找该几何线串上的点

如何通过使用几个查询来计算多个表中的内容?)。

(note: the_geom is a geometry value (TYPE: LINESTRING), in this case i random them for readability)

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

[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?).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玩物 2025-01-11 00:37:34

您要查找的函数是 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;

与 < a href="http://www.postgis.org/docs/ST_LineMerge.html" rel="nofollow">ST_LineMerge 您可以从多行转换为 LineString 但有一个警告,如果多行不能合并后,它将返回多行而不进行任何修改。请参阅 ST_LineMerge 文档,了解 ST_LineMerge 可以做什么或不能做什么。

The function you are looking for is ST_Union, you need to use it with the aggregate form:

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;

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文