Skip to main content
removed closing and redundant signature
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

use the ST_Segmentize() function (http://postgis.net/docs/manual-1.4/ST_Segmentize.html). Then split the linestring on each vertex:

SELECT ST_AsText(ST_MakeLine(start_point,end_point)) as geom FROM
(
    SELECT 
        ST_Pointn(geom, generate_series(1, ST_NumPoints(geom)-1)) as start_point, 
        ST_Pointn(geom, generate_series(2, ST_NumPoints(geom))) as end_point
    FROM (
        SELECT ST_Segmentize(ST_GeomFromText('LINESTRING(0 0,0 50)'),5) as geom
        ) as line
) as tmp;       

linestring segments shorter than the treshold ('5' in this example) will stay the same, of course.

Regards, Christian

use the ST_Segmentize() function (http://postgis.net/docs/manual-1.4/ST_Segmentize.html). Then split the linestring on each vertex:

SELECT ST_AsText(ST_MakeLine(start_point,end_point)) as geom FROM
(
    SELECT 
        ST_Pointn(geom, generate_series(1, ST_NumPoints(geom)-1)) as start_point, 
        ST_Pointn(geom, generate_series(2, ST_NumPoints(geom))) as end_point
    FROM (
        SELECT ST_Segmentize(ST_GeomFromText('LINESTRING(0 0,0 50)'),5) as geom
        ) as line
) as tmp;       

linestring segments shorter than the treshold ('5' in this example) will stay the same, of course.

Regards, Christian

use the ST_Segmentize() function (http://postgis.net/docs/manual-1.4/ST_Segmentize.html). Then split the linestring on each vertex:

SELECT ST_AsText(ST_MakeLine(start_point,end_point)) as geom FROM
(
    SELECT 
        ST_Pointn(geom, generate_series(1, ST_NumPoints(geom)-1)) as start_point, 
        ST_Pointn(geom, generate_series(2, ST_NumPoints(geom))) as end_point
    FROM (
        SELECT ST_Segmentize(ST_GeomFromText('LINESTRING(0 0,0 50)'),5) as geom
        ) as line
) as tmp;       

linestring segments shorter than the treshold ('5' in this example) will stay the same, of course.

Source Link
chriserik
  • 1.3k
  • 1
  • 8
  • 17

use the ST_Segmentize() function (http://postgis.net/docs/manual-1.4/ST_Segmentize.html). Then split the linestring on each vertex:

SELECT ST_AsText(ST_MakeLine(start_point,end_point)) as geom FROM
(
    SELECT 
        ST_Pointn(geom, generate_series(1, ST_NumPoints(geom)-1)) as start_point, 
        ST_Pointn(geom, generate_series(2, ST_NumPoints(geom))) as end_point
    FROM (
        SELECT ST_Segmentize(ST_GeomFromText('LINESTRING(0 0,0 50)'),5) as geom
        ) as line
) as tmp;       

linestring segments shorter than the treshold ('5' in this example) will stay the same, of course.

Regards, Christian