I am a beginner in pgrouting. I have two tables in my postgres database. A street table, where each segment (see red line) carries an Id (ogc_fid). Additionally I have a nodes table (see brown points below). Each point also carries a unique Id (ogc_fid). The nodes below do not intersect at overpasses and underpasses.

enter image description here

Based on the nodes table I want to find the shortest path. However, first I have to assign the nodes ID as source and target node to my street table. And split the streets based on the nodes. (so that each segment is connected to a source and target node from the nodes table)

However, when I use following example from the tutorial pgrouting create topology

SELECT pgr_createTopology('streets',0.001,'geom','ogc_fid','source','target');

The results are worse, because it doesn’t node the graph correctly (see below) and additionally it nodes overpasses and underpasses. This is why I want to use my nodes table instead of the automatically generated verticesstreets_verticec_pgr enter image description here

My question: Is there a way to assign the ogc_fid from the nodes table as source and target value to my streets table based on the digitized direction? Does anyone have useful links related to this issue?

1 Answer 1


pgRouting does not automatically break lines at intersections to create new nodes. As far as I am aware, it also does not allow you to "ignore" intersections that are already noded. However, the first problem provides an indirect solution to the second, because if you make two lines cross without breaking them into a node, they will not be connected and accurately model an over/underpass scenario.

You will have to pre-process the data to clean it of topological problems. v.clean is available in QGIS (which I can see you are using from the screenshots) and can be used with tool=break,snap to node all the intersections. However, you will have to go back and "de-node" the aforementioned under/overpasses to keep them semantically valid.

  • I don't want to create new nodes. I want to create a topology based on the brown nodes rather than the streets_verticec_pgr
    – lazzat
    Feb 17, 2019 at 17:24
  • @lazzat, I think that the topology is created from the streets geometries (start and end point), not from the points geometries. Split and Dump each street in each point that Touches it, and then create the topology. Feb 18, 2019 at 0:48

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.