# Travel time for shortest path (by distance) in QGIS

I have a network with previously calculated and direction-dependent travel time for each edge (`speed_fw` for drawing direction and `speed_bw` for against drawing direction). I prepare the network in QGIS as proposed within this answer, i.e. I double the geometry of the network with a forward and backward version of each edge.

The Shortest Path (Point to Point) algorithm outputs a `cost` field which contains the distance traveled in meters for the shortest path option and the time traveled in decimal hours for the fastest path option. I need distance and duration for both cases. Obtaining the distance for a fastest route is quite simple because the length can just be calculated using the field calculator (when not considering elevation for exact length calculation). But what if I need the time traveled for a shortest route option?

I would like to know if there is a simpler way to do this in QGIS than this workflow:

1. Compute the shortest route between starting point A and destination point B.
2. Rename `cost` column to `distance`.
3. Intersect the underlying network (input layer) with the calculated shortest path (overlay layer), resulting in a "network" that only contains all edges of the previously calculated shortest path from A to B.
4. Compute the fastest route using the intersected layer (using the `speed` field extracted from `speed_fw` and `speed_bw` for the doubled network).
5. Delete all fields except the `cost` field for the resulting route layer and rename the field to `hours`.
6. Add an `hh:mm:ss` field for the duration in hours, minutes, and seconds and calculate the value from the decimal `hours` field using an appropriate formula.
7. Intersect the original shortest path with the attributively modified fastest path and save it to disk. It now contains the fields `start`, `end`, `distance`, `hours`, and `hh:mm:ss` (see screenshot).

In step 3 it is important to not swap input and overlay layers. This leads to wrong results for travel time calculation as the features from the overlay layer are being modified.