【发布时间】:2014-06-27 14:50:13
【问题描述】:
我有 Linestring (0 0 , 2 4 , 5 5);
我需要以如下形式输出:
x (1st cell) || y (2nd cell)
0 || 0
2 || 4
5 || 5
多边形也是如此。 该怎么做?
【问题讨论】:
标签: postgresql postgis
我有 Linestring (0 0 , 2 4 , 5 5);
我需要以如下形式输出:
x (1st cell) || y (2nd cell)
0 || 0
2 || 4
5 || 5
多边形也是如此。 该怎么做?
【问题讨论】:
标签: postgresql postgis
您可以将 ST_X 和 ST_Y 与 ST_PointN 结合使用来获取单个点的 x 和 y,并使用 generate_series 为线串的每个点创建索引,例如,
with line as (select ST_GeomFromText('LINESTRING(0 0, 2 4, 5 5)') as geom)
select ST_X(ST_PointN(geom,num)) as x,
ST_Y(ST_PointN(geom,num)) as y
from line,
(select generate_series(1, (select ST_NumPoints(geom) from line)) as num)
as series;
【讨论】: