first time posting please ask for more details if not enough provided.

I am using OSM road data and have created postgres topology for them. I am now cleaning up the data before exporting it for network analysis.

I have encountered a problem that I am struggling to resolve for (the many) cases where a bridge goes over a road. In my topology a node has been created where they cross, but it is of course impossible to turn off a bridge on to the road underneath, so my network analysis will create incorrect routes.

example of problem junction

In this example the node id is labelled in red and the edge id is labelled in white. For example on node 29, I need to prevent the possibility of routing along edge 43 -> edge 37. Also see node 22, this node must be preserved as edges 35 and 29 merge into edge 25, but it needs to be removed from edges 37 and 26 and replaced with one disconnected edge.

The roads have a 'layer' attribute associated to them (from OSM I believe) which ranges from -5 to 5, which might be used as a flag however I've struggled with it so far.

Also, each edge has a weight attribute that must be preserved in the final output. All I require as output is a CSV of n1, n2, weight.

The dataset is large (one country), and I'd prefer a solution in postgres, however I could explore other solutions in python, R etc.

It strikes me that this must be a common requirement when cleaning road data for network analysis but I've struggled to find any documented examples.

  • 1
    I highly reccomend you this tool github.com/Tristramg/osm4routing2 to get the nodes and edges. You need to get an OSM file of your zone. I use a plugin for qgis for this. Then convert this osm file to pbf format. Then use this pbf with this plugin. (You need to install rust). – Jose Hermosilla Rodrigo Dec 3 '18 at 19:51
  • In OSM these nodes which you labeled in red are not part of both roads! There won't be a connection between edge 43 and edge 37. Otherwise this is a map data error. Please take a closer look at your data. If you still see this problem in OSM then the map data needs to be fixed. – scai Dec 4 '18 at 7:33
  • how did you create the topology? did you simply node the network by spatial intersection (e.g. pgr_nodeNetwork)? the point is, and what both comments above imply, this is a data and import task; 'cleaning' these connections is not the way to go. specialized import tools (e.g. osm2pgrouting) should keep the topology that is implemented within the (OSM) data/attributes. – ThingumaBob Dec 4 '18 at 9:27
  • 2
    @JoseHermosillaRodrigo Thank you all for your comments. You are all quite right, hadn't noticed the error was made before creating topology and assumed that was when the problem started. Downloaded .pbf again and osm4routing2 worked wonderfully. Thank you all. – cts Dec 4 '18 at 13:28
  • @ThingumaBob You were correct, thank you for your help. – cts Dec 4 '18 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.