I try to split a line into 2m segments but somehow the function ST_SEGMENTIZE returns the whole line assigning just one id.

An example:

CREATE TABLE line(name char(10), geom geometry);

INSERT INTO line VALUES('line','SRID=32637;LINESTRING(1 1, 1 3, 2 3, 3 3, 3 2, 4 2, 5 3)');

SELECT ROW_NUMBER() OVER() AS id, ST_AsText(ST_SEGMENTIZE(geom, 2)) AS geom FROM line;


id  geom
1   LINESTRING(1 1,1 3,2 3,3 3,3 2,4 2,5 3)

How can I achieve to get 2m segments from my line-input using PostGIS 2.5.1?


ST_Segmentize will not split the input, it will add vertices to the original geometry so that the distance between vertices is the specified distance.

You may be looking for ST_LineSubstring instead, like in this answer

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.