3

I have 2 data sets that I need to measure the distance between using road lines: 1

In this example I want to connect the red points to their nearest blue point.

Whilst this is easily done with a single end point I have been trying to figure out a way for it to find its the nearest blue point and show a road line route to it.

Using the "Shortest path" tool combined with OSM maps works but you must manually select the end points this would be all red points to single blue point etc etc. I have been unable to find a method to doing this.

I have tried the plugin "ORSTOOLS" which seems to help in the sense that I can select the 2 layers and connect them however it is seemingly at random i.e not the nearest point. I have tried a plethora of filters and still no joy.

How can I achieve this?

1 Answer 1

3
  1. Run the Shortest path (point to layer) tool as batch process. Open the tool and click the Run as Batch Process... button. 2
  2. Then fill the third column (Start point) with the Add Values by Expression... option. 3 Use this expression to fill the Start point column.
    aggregate(
        layer:='blue-layer name/id', -- put inside quotes the name/id of the blue 
        point layer
        aggregate:='array_agg',
        expression:=$geometry
    )
    
    Then scroll down the table and remove the last row, this row is created by default, so we don't need them.
  3. Fill the other parameters:
    Vector layer representing network, Path type to calculate, Vector layer with end points: will be always the same, so fill the first row and then use the Fill Down option 4
    Shortest path (output): You can create temporal layers for all this processes and then merge them all in a single layer. So fill the first row with this string TEMPORARY_OUTPUT and then use the Fill Down option.
  4. Remember to activate the Load layers on completion option. 5
  5. Finally use the Merge vector layers tool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.