10
votes
Accepted
PgRouting : Shortest path starting from the closest vertex not the closest node
While still not in the official release, the withPoints family of functions is in a stable state since pgRouting 2.2 (?) and provides a dynamic interface for temporary nodes in a graph, i.e. routing ...
5
votes
Accepted
pgrouting no result // topology problem
EDIT 3:
After a long discussion in the comments I reviewed my answer, taking the sample data and it´s upload into PostgreSQL from within QGIS into account. I deleted my EDIT 2 as it became useless.
...
5
votes
pgr_dijkstra function with geometry column in result
Join to table ways is as for now only solution (BTW recommended in all official documentation and workshops)
5
votes
Accepted
How to convert a shapefile into a graph in which use Dijkstra
The sg module uses Fiona to read the shapefiles (see shapegraph.py
) and if you can use the module, therefore Fiona is installed.
If you cannot use nx_shp.py (because of osgeo) and you have problems ...
3
votes
Accepted
How can I calculate the shortest path between 2 points and insert the line result as a feature in a layer?
Your code is working for me without problem. I've try it in the QGIS python console.
When i run it with a first start and end point, i get the red line in the cable layer then i run the script with ...
3
votes
Using python QGIS network analysis library to calculate short path based on speed and distance?
I'm using Ubuntu 14.04, QGIS 2.8.1-Wien and python2.7.
Feature.attributeMap() does not work.
After much struggles with the undocumented way of implementing new ArcProperter's, here is my working ...
2
votes
How does pgr_createTopology assign source and target?
I think your roads table is not "noded" correctly.
In the pgRouting topology model, each row of the roads table is an edge, that connects two (and only two) nodes.
Source and target columns are ...
2
votes
Accepted
Force closest facilities take the same route
You cannot make modifications to the Closest Facility solver directly from ArcMap without writing your own solver with ArcObjects and say Visual C++ or C#. Look for more details here Custom solver.
...
2
votes
Pedestrian routing using pgRouting
The first thing is to get proper data - assuming that in OSM there is some you have to create a network from it. I'm using osm2po which is producing graph with info about assignation of road-types. ...
2
votes
Using python QGIS network analysis library to calculate short path based on speed and distance?
I think you don't need QVariant. I'm trying to create my own Properter for bike trips which (as a start) excludes freeways and roads that haven't been built yet. In my road layer, these are ...
2
votes
Accepted
Shortest path problem from A to B on routing engines
You can get rid of such subnetworks otherwise it is harder as you'll need to decide for a 'cost factor' such distances need to be multiplied with.
E.g. if you have A' and A'' and B' and B'' there are ...
2
votes
Shortest path between cities without duplicate calculation (many-to-many)
Since no one joined in, and if you don´t mind, I´ll share some thoughts without this being a satisfying answer (I share a work-related intereset in this).
I highly doubt you have much of an ...
2
votes
Accepted
PGrouting costs
The cost of pgRouting is used for the cost function. In your case the cost is "score * penalty".
The pgr_dijkstraCost() function is mainly for convenience, for example when you request multiple ...
2
votes
Accepted
Bounding box in Dijkstra algorithm (many to many)
Prepare the bbox and pass it as text into the edges_sql:
Updated
SELECT nodes.id,
SUM(pgr.cost) AS "Aggregated Cost"
FROM (
SELECT pwn.id,
pwn."nearest_mz",
pwn."...
2
votes
Accepted
Incorrect Shortest Paths
This looks like the correct path, but it is badly drawn on this projection.
The route heads north out of Brisbane, then turns right and hits the edge of the map. The red line across the world is ...
2
votes
Accepted
pgr_dijkstra select shortest path for pairs
What you are looking for has been added to pgRouting recently and is available under the name "Combinations", for example the Dijkstra implementation: https://docs.pgrouting.org/latest/en/...
2
votes
Accepted
The distance between the points of two layers
You can perform your analysis with QGIS by QNEAT3 plugin using OD-Matrix Algorithms, here you find algoritms description QNEAT3 - OD-Matrices .
The function OD-Matrix calculates travel distance and/or ...
2
votes
After pgr_createTopology, how should I use pgr_dijkstra?
Like explain in the documentation the pgr_dijkstra function need the following parameters :
Edges SQL : A string that represents a SQL query for extract the edges from your edge_table.
start_vid : An ...
1
vote
Accepted
Routing only with specified points
My understanding of PGRouting is that when you create a network from a line dataset, it will build a 'ways' table, but most importantly build a 'osm_nodes' table from the nodes of the 'ways'.
The ...
1
vote
How to limit the search for facilities to only 1 unit with PG Routing? ... Closest Facility in PostGIS?
Well, finally I found a solution, more than a week ago, that works fine for me..
So, I want to share it, if someone else has encountered the same problem. I'm aplying
this to cities from Chile......
1
vote
Dijkstra/Finding shortest path gives back a tree with only -1 in it
I lost whole week to migrate my old dijkstra code from QGIS/Python 2x to 3x...
Finally I found out that some issues in qgis.anylysis (QgsVectorLayerDirector, QgsGraphBuilder, QgsGraphAnalyzer) are ...
1
vote
pgr_dijkstra one to many
try to use the pgr_bdDijkstra function. This function generates a route from one origin to several destinations.
--Exemple
SELECT * FROM pgr_bdDijkstra('select id, source ,target, cost from edge',...
1
vote
Selecting lines with start and end points inside polygons but do not cross them with PostGIS
St_difference will always return a line in your case, with a "hole" in the city buffers. Your second query returns nothing because each line do intersect with the start/end buffer.
To get a working ...
1
vote
Selecting lines with start and end points inside polygons but do not cross them with PostGIS
Well, I found an error in my code, I forgot to create a buffer only around cities with an importance < 2.
But I also found the right way to select it, by using a join, counting the number of ...
1
vote
pgr_Dijkstra: iterate/loop through a table with multiple OD pairs one-by-one
pgr_Dijkstra caan also solve 1->n and n->m shortest path.
When you look at the function documentation you will see, that you can pass an array of start or end ID's.
SELECT * FROM pgr_dijkstra(
...
1
vote
How can I insert the result of the dijkstra algorithm as a feature in a table with PyQGIS?
This applies for QGIS 2.18: You may first create a (memory) layer (if you don't already have one) and a data provider and add it to the registry and the layer list using the following code:
my_lyr = ...
1
vote
Calculate shortest path and distance between multiple OD pairs using pgr_dijkstra one-to-one
do you mean finding the shortest route from all points to all other points on your network?
That's possible with the All Pairs Shortest Path, Floyd-Warshall Algorithm but in "big O" notation it's O(...
1
vote
Accepted
Syntax of pgr_dijkstraCost()
I wouldn't use a loop because you'll still have the issue that any plpgsql you write has to commit as a transaction so you'd probably still run out of memorty.
However, psql has a nice feature called ...
1
vote
pgr_dijkstraCost() Many-to-Many exceeding RAM disponibility
I had a similar problem and I solved it like this:
You can simply break the job into pieces, by running more than one queries and creating more than one tables. For example, if the values of your "...
1
vote
Create shapefile line from a list of point coordinates in a stand-alone python script
The result of the PyQGIS script is a list of points (point_route)
In this example, the point_route result is (7 points between pStart = QgsPoint(110579.17281126765, 116585.26070464966), point 7, and ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
dijkstra × 63pgrouting × 36
postgis × 15
postgresql × 11
shortest-path × 11
qgis × 10
pyqgis × 8
routing × 6
python × 5
graph × 5
osm2po × 4
arcgis-desktop × 3
geoserver × 3
openstreetmap × 3
network-analyst × 3
astar × 3
geotiff-tiff × 2
network × 2
postgis-2.0 × 2
loop × 2
osm2pgsql × 2
osm2pgrouting × 2
network-analysis × 2
qgis-network-analysis × 2
arcpy × 1