Postgres拆分LineStrings并转换 [英] Postgres split LineStrings and convert
本文介绍了Postgres拆分LineStrings并转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是如何在PL/pgSQL中构建一个函数来做到这一点:
my question is how to build a function in PL/pgSQL to do this :
我有很多这样的线串.
Linestring((3.584731 60.739211,3.590472 60.738030,3.592740 60.736220))
我需要将每个Linestring拆分为一个Substring,然后再次将其拆分为2个坐标.
I need to split every Linestring in a Substring and split it up again in 2 coordinates like this.
3.584731 60.739211
x1 y1
3.590472 60.738030
x2 y2
3.592740 60.736220
x3 y3
以此类推. 保存答案并将其转换为双精度,以便我可以计算出分数.
And so on with the other points. Save the answers and converting into a double so I can calculate with the points.
推荐答案
使用 ST_DumpPoints :
SELECT ST_X(d.geom), ST_Y(d.geom)
FROM ST_DumpPoints(
'Linestring(3.584731 60.739211,3.590472 60.738030,3.592740 60.736220)') AS d;
st_x | st_y
----------+-----------
3.584731 | 60.739211
3.590472 | 60.73803
3.59274 | 60.73622
(3 rows)
这篇关于Postgres拆分LineStrings并转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文