I'm trying to build a model that will calculate the shortest path from several origins to one destination.

So I have 3 georeferenced vector layers:

  • A line road network
  • A point layer containing terminals
  • A point layer containing a single point representing a mill

My model does a few things to achieve these layers, but I think that is irrelevant for this question.

Now I want to calculate the shortest path from each of the terminals to the mill. If I run the tool outside of the processing modeller its easy peasy, just choosing from the terminal layer to a point I click with the mouse on the map using the tool "Shortests Path (layer to point)". The thing is I want to automate this and in the model tool there is a box for coordinates instead of the mouse clicking part. I want QGIS to read the coordinates from the mill point in the vector layer and insert these in the coordinate box.

  • Welcome to GIS.se! Could you click 'edit' and add some more details about your data? What have you done so far? – Simbamangu May 14 '18 at 13:13
  • I've edit the post to try and make more sense, thank you for the interest so far! – Christian May 14 '18 at 14:11

You could add a point parameter to your model. Then you'll be able to select that parameter as the End Point in the "Shortest Path (layer to point)" tool. When you run the model, you'll need to define the point every time.

However, it sounds like you're using the same End Point every time you run the model. In that case, you should use a fixed value for the End Point.

To get the coordinates for your point, click on the point with the Identify tool. Expand the "Derived" section, and right click on the X coordinate > copy attribute value. Paste the X value into the model, and repeat for the Y value.

enter image description here

Be sure to enter the coordinates without parentheses, like this: x,y

Not like this: (x,y)

  • Very nice, but I will be running the model with different endpoints. I want the model to define the endpoint automatically. I was thinking there is a way to extract the coordinates from the vector point, put them in point parameter and feed that to the "shortest path (layer to point)"-tool. Any ideas on how to do that? Thank you for your input! – Christian May 15 '18 at 5:55
  • Please edit your question to include information about the endpoint layer. What attributes does it have? Do you want the model to iterate through all the features of the endpoint layer, or only some of them? – csk May 15 '18 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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