[pgrouting-users] pgrouting Dijkstra: non-vertex data routing
McDonaldR at angus.gov.uk
Thu Jul 23 01:15:41 PDT 2015
Hello Yang Zhang
There are some good resources on anitagraser.com and this post shows how to associate a point (in this case airports) to the nearest network node and then solve the routing problem: http://anitagraser.com/2011/02/12/drive-time-isochrones/
The first bit of SQL will do what you want, I think.
ALTER TABLE airport
ADD COLUMN nearest_node integer;
CREATE TABLE temp AS
SELECT a.gid, b.id, min(a.dist)
min(distance(airport.the_geom, node.the_geom)) AS dist
FROM airport, node
GROUP BY airport.gid) AS a,
(SELECT airport.gid, node.id,
distance(airport.the_geom, node.the_geom) AS dist
FROM airport, node) AS b
WHERE a.dist = b. dist
AND a.gid = b.gid
GROUP BY a.gid, b.id;
SET nearest_node =
WHERE temp.gid = airport.gid);
Hope that helps
Ross McDonald | GIS Data Coordinator | Resources Department, IT Division | Angus Council, Angus House, Orchardbank Business Park, Forfar, DD8 1AT
T: 01307 476419 | F: 01307 476401 | E: mcdonaldr at angus.gov.uk<mailto:mcdonaldr at angus.gov.uk>
From: pgrouting-users-bounces at lists.osgeo.org [mailto:pgrouting-users-bounces at lists.osgeo.org] On Behalf Of Yang Zhang
Sent: 22 July 2015 23:51
To: pgrouting-users at lists.osgeo.org
Subject: [pgrouting-users] pgrouting Dijkstra: non-vertex data routing
I have some data samples, they are some traffic accident locations (have shape files) I really want to use the dijkstra function of pgrouting to look into their shortest distances between each other. However, I noticed that dijkstra requires all the points need to be the vertices of a topology. But obviously my data points are not the vertices of the road network. Is there any way to integrate my data points to the road network and make them vertices too? What is the good approach to route non-vertex data like this? Thank you.
This message is strictly confidential. If you have received this in error, please inform the sender and remove it from your system. If received in error you may not copy, print, forward or use it or any attachment in any way. This message is not capable of creating a legal contract or a binding representation and does not represent the views of Angus Council. Emails may be monitored for security and network management reasons. Messages containing inappropriate content may be intercepted. Angus Council does not accept any liability for any harm that may be caused to the recipient system or data on it by this message or any attachment.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pgrouting-users