I have built a network using Ordnance Survey's ITN data and I can solve routes across the network. What I need is to build in grade separation topology for overpasses and underpasses on the network so that my routing solutions do not drop off bridges onto roads underneath in an attempt to make the shortest path possible. Does anyone have any pointers as to where to start?

I am using PostGIS 2.0.3, pgRouting 1.0.7dev and Postgresql 9.2 on Windows.

  • @tqhien - thanks for the suggestions. I will look at my network table and pgRouting 2 and let you know if I have any success. – mixedbredie Aug 14 '13 at 11:31
  • @uffe - I will look at RW Net 4 if I can't get pgRouting to do what I need it to. – mixedbredie Aug 14 '13 at 11:32

When loading data to PostGIS, there's no topology information associated with them. To create a useful topology the data needs to be “noded”. This means that where two or more roads form an intersection there it needs to be a node at the intersection and all the road segments need to be broken at the intersection, assuming that you can navigate from any of these segments to any other segment via that intersection. (Extract from pgrouting 2.0 documentation).

In your case, it seems that some nodes are common between bridges over roads and underneath roads. I don't know if those nodes were given in the ITN data or if you created them.

So you have to pass a clean network to pgrouting :

Let's say you have a bridge (A-B-C) and a road underneath (D-B-E) :

Network example

The table you pass to pgRouting is like :

source | target | geometry           | cost
   A   |   B    | LINESTRING (A,B)   | cost_ab
   B   |   C    | LINESTRING (B,C)   | cost_bc
   D   |   B    | LINESTRING (D,B)   | cost_db
   B   |   E    | LINESTRING (B,E)   | cost_be

You have to modify it to

source |target | geometry            | cost
   A   |   C   | LINESTRING (A,B,C)  | cost_ab+cost_bc
   D   |   E   | LINESTRING (D,B,E)  | cost_db+cost_be

You can create a temporary table and use some case statements to fill columns/filter your grade and generate the modified network.

Note that pgRouting 2.0 documentation gives an example (but with new methods) : pgRouting 2.0 Routing topology

  • olg pgRouting function assign_vertex_id works correctly if our data is "correct", it uses only start and endpoints for edge/node table generation. One could assume that current version works same way. Offcourse if you have bad data , its problem. If you have 3d data you can try use it to clean / merge roads to longest "correct" linestring – simpleuser001 Aug 2 '13 at 12:20
  • I used your example to build my network with grade separations and have a (mostly) complete solution here: gis.stackexchange.com/questions/15609/… – mixedbredie Nov 7 '14 at 21:19

If unsupported by pgRouting, our RW Net 4 package can handle grade separations or Z-levels as they are also called. We also offer an ITN converter for easy import.


I had the same problem and wrote a simple .Net ITN pre-loader to merge the raised links:


I don't think you need to merge the lower road links; pgrCreateTopology only creates a node if both roads use point B so you only need to remove it from the raised road.

  • That looks like a good solution. I load the data with GoLoader and it creates a swathe of supporting tables which include the grade separation, one way streets and turn restrictions. Some PostgreSQL functions and queries did the job for me in the end. – mixedbredie Nov 7 '14 at 21:24

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.