Is there a way to clip a linestring based on distance? For example, linestring from a to b is 150 meters. I would like to get the linestring from a to a point that is is 75 meters away from a following the a-b linestring.

What I have thought until now is to get the line NpointCount and start adding together small line segments until I get close to 75 meters, but still, how am I supposed to add the final line segment?

I hope I am making sense here..

thanks in advance!

1 Answer 1


In PostGIS it's a two-stage process. First you need to find the overall length of your line geometry with ST_length()

Say that produces a value of 150. Then you need to divide your desired length, 75, by the total length, giving you 0.5. Finally, with that value call ST_Line_Interpolate_Point() or ST_Line_Substring() to return the substring rather than a point.

  • thx, i ll give it a try!
    – Antony
    Jan 26, 2012 at 15:57
  • My bad, I meant ST_Line_Substring() postgis.org/docs/ST_Line_Substring.html not ST_Line_Interpolate_Point() Jan 26, 2012 at 16:12
  • Right, your suggestion works fine but it seems that postgis has problems converting some specific multilinestrings into linestrings which is necessary before calling the st_line_substring function. Is there a way to come around this postgis issue?
    – Antony
    Jan 27, 2012 at 16:02
  • If your lines are as multilines, you'll need to split them up first. You can use ST_Dump (postgis.refractions.net/docs/ST_Dump.html) and pass the results into your query. Jan 27, 2012 at 16:09
  • You are right, some of my lines have a double ending like a double fork and that is probably causing trouble to postgis...Anyway, thank you very much for your help!
    – Antony
    Jan 27, 2012 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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