I want to find the distance (km) between each origin point to the closest destination point (restaurants) using pgrouting.
I have 3 tables
- my road network with nodes and edges
- 140 origin points - centroids of neighbourhoods
- 3000 destinations - restaurants
The road network already has source, target, length (cost) and topology.
I have used tutorials that specify in the SQL query which nodes to calculate cost between such as this one:
SELECT seq, id1 AS source, id2 AS target, cost FROM pgr_kdijkstraCost(
'SELECT id, source, target, cost FROM edge_table WHERE cost >= 0',
10, array[4,12], false, false
Instead of explicitly referencing origin as "Node 10" and Destinations as "Nodes[4,12]" is there a way to reference my tables that list all 3,000 destinations?