3

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

2

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.

  • where can I do that in QGIS? I've tried various v_clean tools like snap, break, rmdupl and bpol without success, must be the tolerance. Or are you suggesting that there is a snap function in QGIS so this is done correctly when I draw the lines? If so, how to enable it? – johlund Dec 22 '13 at 15:26
  • @user1151640 lmgtfy.com/?q=qgis+enable+snapping – underdark Dec 22 '13 at 15:29
  • haha, my first "I'll google it for you"-link. You're right, I should have been able to figure that out. But I had no idea that digitizing and snapping was the words to use. I'm very new to this. I already have shpfiles with all the stations and another shp with lines between the points (stations). Is there possibly an easier way to do this then to draw everything manually? – johlund Dec 22 '13 at 15:45
  • If you already have a shp with lines between stations, why would you even try to draw them manually? Please update your question and include all relevant information about data you already have and exactly what you want to achieve. There are many ways to skin a cat and to find the most suitable one for you, we need all available information. – underdark Dec 22 '13 at 15:56
  • No I added the "sort" column to make Points to Path work. I have two more buss routes to add (with 30 stops each) and the rail routes with another 20 stops. When I tried to manually draw the lines from a new layer (with snapping) it didn't work in pgRouting. When I draw a line with snapping enabled and try to run driving_distance etc the network is broken. (When I zoom in enough I find broken lines here and there after importing it with DBManager. I'm about to give up and install parallels to finish up this school project in Arc. – johlund Dec 25 '13 at 12:07

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.