# Route between two point layers following streets

I have a problem to be solved with shortest path route.

What I have:

• layer 1 with startpoints
• layer 2 with endpoints
• layer 3 with streets (lines)

These two point layers are originally the start and endpoints of a layer of lines, but now i'm looking for an alternate route for these lines, using the shortest path algorithm.

I want to calculate the shortest path between these two point layers. The two pointlayers have both an attribute where the startpoint and endpoint have the same unique value, so they can be connected on that attribute value I suppose.

I already did a try with pgRouting: i followed a tutorial and already did pgr_createTopology on the streetlayer, so the vertices of these streets are already made.

But now i'm stuck, can for example pgr_dijkstra be automised for a whole layer? (because each pointlayer contains +10.000 points)

My idea was to use nearest neighbour to link the start and endpoints to a vertice of the streets. And then use pgr_dijkstra on that streetlayer so that the shortest path is calculated when the values of the pointlayer are the same, so startpoint(UNIQUE_VALUE) = endpoint(UNIQUE_VALUE).

How is this possible, or does someone have another solution?

• check the accepted answer here - i had the same problem with students and schools and found a solution in the answer: gis.stackexchange.com/questions/231786/… – DPSSpatial Aug 7 '17 at 22:42
• But how can I implement the restriction that the startpoint and endpoint are from the same (original) line? I have implemented already all the nearest vertex of the street network into the 2 tables with start- and endpoints. – ledobbel Aug 8 '17 at 22:52
• I think i'm very close! I have a table now with the startvertex and the endvertex that should be implememented in the pgr_dijkstra(). They are in a table with column1=startvertex and column2=endvertex. How can I now execute the whole table? – ledobbel Aug 8 '17 at 23:11