问题
my question is how to build a function in PL/pgSQL to do this :
i have many linestrings like this.
Linestring((3.584731 60.739211,3.590472 60.738030,3.592740 60.736220))
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.
回答1:
Use ST_DumpPoints like this:
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)
来源:https://stackoverflow.com/questions/27035149/postgres-split-linestrings-and-convert