I have an existing pgrouting network topology that I would like to add a road to. The road is a linestring from a shapefile and will intersect several roads in the existing network. Is there an easy way to add the road into 'ways' so it is segmented properly and new vertices are created at the intersections?

2 Answers 2


I don't think there is an easy way. You need to

  • split the roads at intersections with existing roads as you said
  • Use source/target ID's when "connecting" to existing road segments
  • create unique source/target ID's for segments that don't connect to existing ones.

Depending on your use case, you might want to try:

1) Split the road at the intersections: https://gis.stackexchange.com/a/71291/37568

2) Insert the results into your road network.

3) Drop the "_noded" and "_vertices_pgr" tables. If for example your table is named "roads", the other two will be named "roads_noded" and "roads_vertices_pgr"

4) Run SELECT pgr_createTopology('roads', 0.000001);

5) Run SELECT pgr_nodeNetwork('roads', 0.000001);

The proper/efficient way is the one by @dkastl, but if you don't care about maintaining node ids and speed is not an issue, you may find this sufficient.

Your Answer

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

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