The process could be divided into two parts
- Select the lines that will form the polylines (get rid of unnecessary lines).
- Form the polylines.
The first part is the most delicate:
It is necessary to create a condition (or several), which must be able to be formalized mathematically in terms of Set theory, and which will decide whether a line should be selected or not.
The most practical approach, although probably the least robust, is that the condition be established in terms of azimuth ranges that the geometry must have to be selected.
I present an example of a set of lines purposely drawn for this answer, which were labeled with their corresponding azimuth. Labels are based on the expression: round( degrees( azimuth( start_point( $geometry), end_point( $geometry))), 1)
.
Two conflicting lines are selected:
Obviously, the azimuth depends on the direction (forward or backward) in which they were digitized. So the condition will be established over opposite azimuth ranges.
If a condition based on azimuth ranges can be established for all (or almost all) of the image, I would think that some conflicting lines that are selected in the first instance would not be a problem, since it would be relatively easy to manually delete them later.
In my case, since I do not want to select the 171.9 azimuth line, one of the edges of my ranges will be 170 degrees (and its opposite 350). The other edge I chose wide because I saw no drawbacks (100 degrees and its opposite 280).
Lower ranges would be more restrictive, but I would prefer to choose more lines (and then delete them), but that all the lines that interest me are selected. Likewise, in some iterations by trial and error, a convenient range can be determined. Also, what condition could I impose so that the 179.1 degrees azimuth line would not be selected if it were within my range? Of course there is an answer, but I don't know it.
I selected by the expression:
(
( ( azimuth( start_point ( $geometry), end_point( $geometry))) >= ( radians( 100)))
AND
( ( azimuth( start_point ( $geometry), end_point( $geometry))) <= ( radians( 170)))
)
OR
(
( ( azimuth( start_point ( $geometry), end_point( $geometry))) >= ( radians( 280)))
AND
( ( azimuth( start_point ( $geometry), end_point( $geometry))) <= ( radians( 350)))
)
And exported selected features as a new layer.
Form polylines is much simpler now.
Note that the polylines must be topologically correct. Each line must start at the exact point at which another ends. By your procedure exposed in the question I have no doubt that this is so. But if necessary, you should clean them first with v.clean.
Polylines are formed with v.build.polylines.
Both GRASS tools are integrated to QGIS.
If any unwanted line has remained (has not been deleted before building the polylines), then three lines will come from one node, and the correct interpretation of the topology is that there will be three different polylines that share that node.
If so, eliminate the unwanted line (or polyline) and rebuild.