Note: This is basically the same question that I asked before in Summing attribute values of overlapping polyline portions in ArcGIS Desktop?, but this time, I'm trying to solve the same problem using QGIS. The reason is, I need to be able to teach/explain the solution to users in a developing country who cannot afford ArcGIS. I'm not an expert in QGIS either. So here is the question:
I have polylines of 80+ bus routes operating in a city. The polylines have attribute values for the number of passengers, number of trips, etc. Many of the polylines overlap at certain areas of the road network.
For example in the image above, the Green Route has 1,000 passengers and travels 20 trips a day while the Orange Route has 500 passengers and 10 trips a day. I'd like to have a final shapefile with data on 1,500 passengers and 30 trips (overlapping areas), but also data on the 1,000 passengers with 20 trips and 500 passengers with 10 trips (non-overlapping areas). This is just a simple example with two routes but I have 80+ in all that overlap in many locations with each other.
What I have done so far:
Step 1: Run "Merge vector layers" to combine all the individual polylines into one shapefile.
What I want to do next:
Step 2: I want to cut/split the overlapping features exactly where the overlaps occur.
Step 3: I want to fuse/merge/join (whatever the correct term is in QGIS) all overlapping line segments, AND add up their numbers of passengers and trips into the resulting feature. 1,500 passengers and 30 trips in the above example.
Step 4: Lastly, I want to, somehow be able to find out which routes whose values have been added together. In the above example, a column saying "Green, Orange" would be nice, but doesn't matter if I get "GreenOrange".
What I have tried so far for Steps 2, 3 and 4:
Multipart to singleparts
Tried to split all overlapping segments, but the splits did not occur exactly where the overlaps start and end.
Created a polygon that covers entire area to try to get all overlapping segments split. Splits did not occur exactly where the overlaps start and end.
Seems to be able to sum up the numbers of passengers and trips, and also able to concatenate the Route Name, but the result is only one feature. In the example, I need to have 5 features as the result.
Join attributes by location
Referring to Merging overlapping lines into one line. QGIS. Requires an Input Layer and a Join Layer. I only have one layer since Step 1, so this can't be it, unless I'm doing it wrong from Step 1.
This just returns the separated lines into one, back to Step 1. I was hoping that it dissolve the overlapping segments.
Same as above.
Result of Step 2: v.clean
Result of Step 3: Aggregate
Final Result, Step 4: Delete Duplicate Geometries
In above image I selected the overlapping line segments. This is how the map looks like:
Two line segments North of the loop are supposed to overlap, but they are now missing. Only a tiny chunk is left.