[GIS] How to draw a simple bus network that works with pgRouting

multimodal-networkpgroutingqgis

What I'm I doing wrong? I've created a new shape layer for lines, I've enabled snapping with 5 map units for that layer. When I draw a line between two of the stops I get a purple marker when I'm at the "right" spot, I click the first stop and then the second, then I close the drawing with a "right click" (I create one line between every stop(point) to be able to specify cost for that certain distance. When I zoom in on the points this is how it looks like and I'm guessing this is the reason that pgRouting doesn't work as well: (I feel like a total idiot, this should be easy but somehow I fail)

enter image description here
enter image description here

Ok, I have now been able to achieve this:

  1. Buss stations as points imported from google earth (saved to my places, imported and saved as a shp from QGIS)
  2. Using the plug Points to Path drawing a single line through all the points.

How can I turn this into a routable network with pgRouting? I'm guessing I'll have to split the long line between my 38 stations into smaller pieces so that I can specify the cost (travel time) between each station.

Can anyone help? It's really frustrating not knowing how to do this..

enter image description here

EDIT: This is what I have:
Three shape files: (See new screenshot)
1. Train stations. Points (RED)
2. Rail network. Lines (BLUE)
3. Buss stations. Points (GREEN)

I also have travel times between all buss stations and between all train stations specified in minutes.

This is what I want to do:
Runt pgRouting stuff like driving_distance and alpha shapes from your (underdark) blog on this combined public transport network i Sweden. I guess I'll have to draw lines between the buss stations? And also connect the train station with the closest buss stations to allow the traveler to change to buss and move further.

Vision:
Manage to merge them into one shape file with travel times between stations specified as COST in the attribute table and where both busses and trains are connected with manually drawn lines that connects them (and have a COST attribute as well to make the analysis more realistic)

(My ultimate christmas answer would be how to turn this into a multimodal network and be able to merge this public network on top of my working road_network, but from what I understand thats hard with pgRouting? Wrote a couple of questions that didn't get answers on that)

How to make this work with QGIS+pgRouting+PostGIS+Postgresql?

enter image description here

OLD QUESTION:
I would like to be able to draw two lines (see attached screenshot, specify the cost for each one and then import the layer to psql with QGIS DBManager and then pgr_createTopology and back to QGIS as a PostGIS layer. I now want to be able to runt pgRouting analysis on this simple bus network with three stops (at the start and the end + where the lines intersect).

With this workflow driving distance wont get me anywhere and Dijkstra only works with one of the lines.. What am I missing here? How would you set this up?

simple buss network

Best Answer

What you need for pgRouting - at minimum - is a table with edges:

edge_id, from_node, to_node, cost
1, 1, 2, 12.0
2, 2, 3, 57.0

Note that geometries of the edges are not necessary for most algorithms. Only the logical topology has to be created.

If you want to have edge geometries: start from the bus/train stop layer and create one edge for every connection (with snapping to the stops layer enabled). You can chose between assigning from_node and to_node ids manually or using one of the built-in pgRouting functions. For the automated process to work, you have to do a good job while digitizing the geometries.

Depending on how many bus/train lines you are planning to add, it might be advisable to try to automate as much of this process as possible. Is the "sort" attribute included in your bus stop data or did you have to add that manually?


Previous answer:

Since the ends of the two lines you show in the screenshot are very far apart, you would have to set the tolerance in pgr_createTopology really high (http://docs.pgrouting.org/dev/src/common/doc/functions/create_topology.html).

Instead you should pay more attention to digitizing the lines correctly by enabling snapping.

Related Question