Calculation of the distance between intersecting lines, but according to existing lines

I will try to briefly describe, namely, it is a forest area and polygons mark some kind of reference area, roads are lines, and there are also tractor roads (the same lines) which in this case are the subject of observation, namely tractor roads start from the road and within that polygon expand and branch (like the veins on the leaves of a tree), what needs to be measured is every single distance from the place where the tractor path forks to the point of exit to the road, but following the tractor path in question...

Of course, this can be obtained using the measuring line tool and slowly clicking on the line, I also tried using the QNEAT3 plugin - from matrix from point as table, but I get a large number of records that are quite difficult and slow to filter.

My thinking goes in the direction of placing points at the intersections of forest roads using extract specific vertices, then at the intersections of forest roads and roads, place a second layer of points and then calculate (measure) the distance between those blue points in the image and yellow x and the network is the blue line.

QNEAT3-routing-shortest path does exactly what I have in mind, but I don't need a vector layer, but only a figure of how long that distance is...and immediately further measurement...or a model that would automatically fill the attribute table and solve everything with one click distance...

Maybe some kind of plug-in like the MEASURE tool, but add the possibility of choosing the "network layer" -> mark the starting point, mark the end point, and the tool itself, following the selected layer, measures the distance.

• This is the sort of problem statement which requires a picture. One paragraph, no matter how massive, can't adequately describe what a graphic or two can. Commented Sep 5, 2022 at 19:53
• Maybe something like this one!! Commented Sep 5, 2022 at 19:57

Basic idea

Create two point layers with the intersection points of 1) tractor/road (start points) and 2) tractor/tractor (where paths split, end points). Then run network tool `Shortest path` in batch mode: once for each point in layer 1/start points, creating a shortest path along tractor path to each end point.

Creating point layers

Use the `Line interesections` tool twice, first to get the intersections of tractor path with road (`intersetion_road`: the start-points), the second time for the intersection of tractor path with tractor paths (layer `intersection_tractor`: the end points).

Using network tool

Then run QGIS native network tool `Shortest path (point to layer)` in batch mode. Run the tool once for each point in layer `intersetion_road`. To do so, for start points click `Autofill... > Add Values by Expression` and add this expression:

`aggregate ( 'Intersections_road','array_agg',\$geometry)`. This will add a new row for each start point.

All other values can be set once for the first row, then click `Autofill... > Fill down`:

You will get a separate line layer for each of the start points (= intersections of tractor paths with roads) and the layers contain separate features with lines along the tractor path to each end point (where two tractor paths split). The attribute table contains an attribute `cost`: this is the distance along the tractor paths from start to end points.

Be aware: denpending on the setting and the geometries you have, there will be some duplicates and empty geometries you can get rid of.

Screenshots

For eachs start point (blue) a separate layer for each branch (here two: yellow and orange) is created. On each layer a separate line to each of the end points (red) is created. Attribute field `cost` returns the length along the network (tractor paths): compare the identical distance from point A to point 5 in attribute table and with measure tool:

Screenshot showing the settings for the project you provided:

In the resulting layer, click the `cost` header to sort the table and see the lines that have a length value. Here for example, to top line (coresponding to the blue line) has a length of 844.2 m:

• Thx, I will tray this soon... Commented Sep 5, 2022 at 20:41
• Atributr field cost are empty... i dont know way? Any way thanks a lot!!! Commented Sep 6, 2022 at 12:40
• All cost attributes are empty or just some? What CRS does your layer habe? Commented Sep 6, 2022 at 18:37
• All cost are empty.... Commented Sep 6, 2022 at 18:51
• After probably a hundred unsuccessful attempts, I saw my mistake. In the column of the output file, I named them all the same and of course the process ran over it... Thanks again... Commented Sep 11, 2022 at 14:23