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)
FROM
(SELECT airport.gid,
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;
UPDATE airport
SET nearest_node =
(SELECT id
FROM temp
WHERE temp.gid = airport.gid);
Hope that helps
Ross
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@angus.gov.uk
···
Hello everyone,
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.
–
Yang Zhang