6

i found how to do it. i converted RgSpeedProperter class from RoadGraphPlugin cpp Source to python. the python class definition is below: from PyQt4.QtCore import * from PyQt4.QtGui import * from qgis.core import * from qgis.gui import * from qgis.networkanalysis import * from qgis.utils import * import qgis class SpeedProperter(QgsArcProperter): def ...


4

Join to table ways is as for now only solution (BTW recommended in all official documentation and workshops)


4

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. The problem is that you initially run pgr_dijkstra on multilinestrings. Next to the topology (that you created), the basic geometric structure for any pgRouting ...


4

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 between arbitrary points. The key here is the points_sql where you specify the closest edge to any of your temporary nodes, and the fraction of line length their ...


3

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 others start and end point and i get the yellow line added in the same layer. and what i get in the attribute table (length and geom calculate with the field ...


3

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 with sg, you can use Fiona and Networkx to create a Networkx Graph. (GSE: How to calculate edge length in Networkx for example). from shapely.geometry import ...


3

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 solution. Also serves as a rogue documentation. class SpeedFieldProperter(QgsArcProperter): """ (attributeIndex, defaultSpeed=2.71828, ...


2

TSP has 2 alternative ways to be called: one uses the euclidean distance as you said, the second one requires a distance matrix as the first argument: SELECT seq, id FROM pgr_tsp('{{0,1,2,3},{1,0,4,5},{2,4,0,6},{3,5,6,0}}'::float8[],1); seq | id -----+---- 0 | 1 1 | 2 2 | 3 3 | 0 (4 rows) It's up to you how to calculate the distance ...


2

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 filled with the id of the roads_vertices_pgr table accordingly. If your roads table is not noded, pgRouting cannot "turn" on non-noded intersections. If I'm right, ...


2

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. However, there is a simpler approach. If you are OK with some Python scripting, this is what you could do with arcpy (Python programming) to tackle this problem: ...


2

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 obviously 4 possible combinations with different distances and 4 potential different paths with different costs (e.g. distance, time or fuel costs) so you have ...


2

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 alternative to get a generalized network like the one you are looking for; this is due to the fact that the adjacency matrix of neighbouring cities you imply (to be able ...


2

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 CLASS_CODE 0 and 9. Here's some code that seems to be working so far for me (still testing). In the shortest path function: directionField = self.roadLayer....


2

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 actually zero metres long. Then the route continues through the Bering Strait and goes north further than the valid EPSG 3857 projection limit of 85N. That explains ...


2

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 time from each origin points to each destination points. To perform this analysis, after have installated QNEAT3 plugin, you have to choose, in processing ...


1

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 solution, you can count the line/buffer intersections and keep only the cases with 2 intersections


1

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 different buffers intersecting each line and selecting only those with up to 2 intersecting buffer. Here's the code : CREATE TABLE "ReseauRoutier".graphtest AS ( ...


1

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 origins/destinations at the same time but are just interested in the total cost. However, if the actual aggregated cost should be a different one than the one used ...


1

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."nearest_poi", ST_Collect(vt1.geom, vt2.geom)::TEXT AS bbox FROM pairs_mz_poi_node AS pwn JOIN <vertice_table> AS vt1 ON pwn."nearest_mz" =...


1

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 still in test phase, so you might try to call built in processing on similar way I did: feedback = QgsProcessingFeedback() crsID = " [EPSG:...


1

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', 35681, ARRAY[34450,34926], FALSE); I hope it helped you


1

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( 'SELECT id, source, target, cost, reverse_cost FROM edge_table', ARRAY[2,11], ARRAY[3,5], FALSE ); http://docs.pgrouting.org/2.4/en/pgr_dijkstra....


1

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 = QgsVectorLayer('Linestring?crs=epsg:31468', 'network result', 'memory') # 31468 is only an example, set the epsg code you require my_lyr_dp = my_lyr....


1

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(n^3) so it will take a LONG time (10 nodes will take 1,000 units of time, 100 nodes will take 1,000,000 units of time...) You may also run out of memory for ...


1

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 \watch since PostgreSQL 9.3. https://www.depesz.com/2013/04/07/waiting-for-9-3-add-watch-sec-command-to-psql/ that allows you to repeat a query over and ...


1

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 "buildingID" are i.e. from 1 to 10000, you can 2 queries instead of one. Run a first query like this: CREATE TABLE results1of2 as ( SELECT start_vid as building, ...


1

You can use Geoserver with views and using parameters to pass, for example, start and destination points. The trick is to use GetFeature WFS request and get (one) geojson response to simply create your layer with OL3. All can be done client-side with Javascript and an ajax request. You may prefer jsonp to allow cross-site AJAX with JSON data. see here


1

thanks for your help, the problem was that my vertexes weren't correctly connected so I reconnected them in geojson.io and relaunched the algorithm and it worked perfectly. I tried the pgr_nodenetwork solution but it created many nodes that I don't need plus it somehow deformed my vertexes, the other problem is that it creates the target and source columns ...


1

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 pStop = QgsPoint(111819.28396552203, 116854.75854462344)), point 22) [(111819,116855), (111576,116688), (111306,116504), (111145,116599), (111005,116681), (...


1

Basically your question is how long is the path represented as points in p. Since you are using a projection that is in meters it is simply a case of iterating through p and calculating the distance to the last/next point. So something like: lastPoint = None d = 0 for point in p: if lastPoint is not None: dx = point.x - lastPoint.x dy ...


Only top voted, non community-wiki answers of a minimum length are eligible