1

I'm running a simply Shortest Path task from the Network Analysis toolbox in QGIS, but it seems that the output doesn't transfer the line attributes, only the start layer attributes. I need the road types and lengths so I can summarise how much of each are traversed.

I've already tried transferring the attributes by converting the lines to points and intersecting them and I've also simply tried intersecting the road network with the output lines, but the result is disconnected segments as it coincides in some parts and in other it just slightly doesn't overlap exactly (which should really be the case as I applied no snapping tolerances to the Shortest Route).

Anyway, this should be simple, but I don't see an option to retain the network attributes.

1 Answer 1

0

Well, there are some minor inaccuracies with the resulted route. There are multiple ways to achieve this which heavily depends on the size of your data.

Here is a rather lengthy, but fast in terms of performance:

  1. First, buffer the roads by 2 meters. This value depends on the level of inaccuracy of route results.

  2. Then select by location: select lines from your network that intersect with your buffer

  3. After that explode the selected lines and get their centroids. Exploding them splits them into straight lines which positions the centroids on the lines.

  4. Next step is buffering the points by the same amount of inaccuracy (2 meters) now you have polygons with the street information.

  5. Explode the routes from the network analysis.

  6. Finally spatial join the buffers with routes.

This should add attributes to the routes. you can dissolve the results based on the ID or name of the roads to have fewer shapes.

I recommend you to create a model in model builder for such lengthy processes.

2
  • 1
    Thanks for the answer. The only issue I have with this is that the buffer might also select roads which connect to the target roads. However, what I did get out of this is the explode function. I think that's how I'll transfer the attributes. Simply explode the routes, then convert them to centroids and intersect them with the roads. That way I'll get the roads data, plus the route attributes derived from the centroids. Thanks for getting me on the right path!
    – MierMoto
    Commented Jun 22, 2021 at 0:10
  • You are absolutely right my friend :). I advised you to do that so the amount of shapes for spatial join is reduced and the process finishes faster. It works without that too. I am happy to help! Commented Jun 22, 2021 at 4:54

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.