2

Using QGIS 2.18.14, I try something around with qgis.networkanalysis module as described here: https://docs.qgis.org/2.18/en/docs/pyqgis_developer_cookbook/network_analysis.html

director = QgsLineVectorLayerDirector(network, -1, '', '', '', 3)
properter = QgsDistanceArcProperter()
director.addProperter(properter)
crs = network.crs()
builder = QgsGraphBuilder(crs)

tiedPoints = director.makeGraph(builder, [start_geom] + target_list)
# target_list is a list of QgsPoints()
# start_point is a QgsPoint()
graph = builder.graph()

Everything seems to work so far, tied point are generated correctly, but when I try to find paths from start_point to the targets by

(tree, cost) = QgsGraphAnalyzer.dijkstra(graph, idSource, 0)

some of the tied_points cannot be reached in the graph (i.e. tree[id_target] =-1 for certain point).

My first thought was that there is something wrong with my vector layer but it seems topologically correct (no gaps or duplicate consecutive point e.g.), no matter if LineStrings or MultiLineStrings.

Since I thought that each tied point should be reachable in the graph, what can be the reason for the 'non-reachability' of some points on such? Could this be a problem of LineString directions in the network layer?

2

Is your road network fully noded? I.e. has separate lines for every intersection? That's a pre-requisite for the network analysis module.

  • I think so. The developer cookbook says: "Two lines that have a common node become connected to each other." so a T-shaped situation has a common node in the triple point, but not common end nodes. So do I have to break such situations in a way that the vector dataset have solely end nodes in common? And does it matter if its type is Lines or Polylines? – Jochen Schwarze Nov 30 '17 at 8:08
  • A "T" intersection must have a node on the straight segment too (eg at the middle of the top line of the "T"). There's no requirement for having either lines or (multi)polylines - either will work. – ndawson Dec 1 '17 at 1:49

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.