I'm working on PostgreSQL and I am trying to create table to generate graphs. I have a table that contains all the objects of a city (points) and another contains the city street. My goal now is to segment the street in small segments that begins and ends with two objects (points). I try with different PostgreSQL query but I can not create a table of links that restrained the source and destination of each seqments ST_pointN actually gives the first and last point in a linestring against me by I want to have all the object on a street with the order to which I may have small segments.

Can pgRouting help me segment the streets and if so how?

  • Please add an image to illustrate the question. Are the points located on the lines or besides them, etc.
    – underdark
    Mar 13, 2013 at 10:21

1 Answer 1


Sounds like you should read about linear referencing.

ST_line_locate_point(LineString, Point) (0-1 value from start) 
ST_line_interpolate_point(linestring, location) 

using those two you get nearest point on road from your point. After that split edges to have node for those point and regenerate graph table

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.