Hello,
I wrote a while back a mail here and posted something on Stackexchange.
https://gis.stackexchange.com/questions/308244/dijkstra-finding-shortest-path-gives-back-a-tree-with-only-1-in-it
My main issue is, that in Qgis 2 there was a fairly simple way to perform a dijkstra analysis. I think you needed like 6 lines overall.
Migrating the same principle to Qgis 3 doesn't work, it always sees the path as not connected although it is. My guess is that the graph isn't created correctly, but I'm not an expert programmer.
I know by now, that there is a workaround using the processing algorithm, but that gets way more complicated and as i mentioned earlier I'm not an expert and that is above my skill-level.
I really would like to have a straightforward approach like there was in Qgis2, where you could create a graph from existing layers, define some properties and then perform the dijkstra on that graph.
Here is the code that I migrated from Qgis2 that doesn't work but that would be great if it could work that way again:
director = QgsVectorLayerDirector(layer, -1, '', '', '', 3)strategy = QgsNetworkDistanceStrategy() director.addStrategy(strategy) builder = QgsGraphBuilder(crs) #crs = project.crs() which is in this case WGS84 tiedPoints = director.makeGraph(builder, [startPt, endPt]) graph = builder.graph() startVertex = graph.findVertex(startPt) (tree, cost) = QgsGraphAnalyzer.dijkstra(graph, startVertex,0)
SincerelyChristoph Dohm_______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
