【问题标题】:how to get points from linestring postgis如何从线串postgis中获取点
【发布时间】: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


    【解决方案1】:

    您可以将 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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-05
      • 1970-01-01
      • 2012-01-26
      • 1970-01-01
      • 2015-09-21
      相关资源
      最近更新 更多