In QGIS I can suggest using a
"Virtual Layer" through
Layer > Add Layer > Add/Edit Virtual Layer....
Let's assume we have two layers
"paths" with its corresponding attribute tables, see image below.
With the following query, it is possible to calculate length of some paths with defined vertexes and each route is characterized by some records.
SELECT p.geometry AS geom,
v1.Name AS "from_point",
v2.Name AS "to_point",
round(st_length(p.geometry),4) AS "path_length"
FROM "paths" AS p
LEFT JOIN "vertices" AS v1 ON st_touches(p.geometry, v1.geometry)
LEFT JOIN "vertices" AS v2 ON st_touches(p.geometry, v2.geometry)
WHERE v1.id <> v2.id
The output Virtual Layer with its Attribute table will look as following
- The output layer will contain some geometry twice, i.e. path
1->2 is the same as
- This approach will only work when paths are broken at vertices and vertices are snapped to paths