I've used the very useful Openroute service to develop a number of routes which I have populated with traffic numbers (on each route). I want each section of road to present the total of a field (across multiple records) on each segment of road.

The routes fan out like tree branches so the routes close to the point of interest have many individual paths overlying one another, until it gets a to point on the network where just the destination is on a route.

I've tried a few ways but I either get a sum of the whole dataset, or a sequence of numbers on all the underlying routes.

I can get the answer the long way around by selecting the underlying routes and then inspecting using the Statistics Panel 'Sum' but I'm sure there must be a much easier cleverer way of doing this.

FURTHER INFO: It’s difficult to visualise as the routes often overlap, but let me try to describe it differently. I have undertaken a set of route plans using open route service. These are sometimes overlaying and sometimes separate. Each individual route line has 4 values attached to it, AM IN (Arrivals in the morning peak), AM OUT (departures in the morning peak), PM IN (arrivals in the PM peak) and finally PM OUT (departures in the evening peak). I want to present vales on the plan that show the total value on each section of the routes, summed together. So for example if routes AB,AC,AD all ran over an element of common route the sum of their values would be presented. For each section of road I want to show the specific value of AM IN /AM OUT on that section of road. Essentially if i select the routes and use the Statistics panel the sum of selected routes shows me the right answer - but this is laborious.

  • 1
    I'm having trouble visualising what you are trying to achieve. Perhaps you could add a diagram and/or screenshot to illustrate your problem further? Commented Mar 22, 2018 at 11:38
  • Ive added more to the description. It’s hard to visualise hope that helps ? Commented Mar 23, 2018 at 14:12
  • I'm still finding this a little tricky to follow, but will join attributes by location using 'take summary of intersecting features' and 'sum' options work for you? Commented Mar 23, 2018 at 14:26

1 Answer 1


If I am understanding correctly, you have a situation like his:

enter image description here

Where each colour is a different route, and they are all sharing a segment in the middle (the black circles represent the start/endpoints of the line segments), but they are in fact duplicates of the same feature, and you want to merge the segments of the routes into single features where they overlap, and sum a certain field at the same time (so in the above image, the middle segment would be the sum of red+blue+green and the bottom-right segment would be red+blue.

If this in indeed the case, then the QGIS plugin Dissolve with stats should get the job done. It can be downloaded from Plugins > Manage and Install Plugins... > Search for "Dissolve with stats".

enter image description here

If your segments have a field that indicates their source id (i.e. if the middle segment in the above image has an id value that is identical across the red, green and blue segments, then you can use this as the Dissolve field. If you do not, you can create a string field in your routes dataset and calculate it to have the field $geometry. Since the segments are from the same source, their geometry should be identical, and could serve as a de facto identifier.

Then, you can choose whatever statistics to be calculated for whatever field you like. In your case, you would want to Sum value in the stat field in the input.

  • Yes thats what Im trying to do. I have noow tried it but it resulted in a python error so didnt present a resultant dataset. Ill persist a little and see if I can get to work. Commented Mar 26, 2018 at 14:11
  • Having given it a few tries it doesnt seem to be working for me. I womder is it anything to do with my routes are ffrom a common origin point. They then are a single line between that and each destination. As shown in the diagram above there are instances where they share commonality and the further out from this point the less roads they share. Do I neeed to break apart the data into individual vectors first ? Commented Mar 26, 2018 at 14:27
  • If each route is just a single polyline feature from beginning to end, then yes, you will have to break them into individual segments, i.e. each segment must start and stop at a "black circle" as per the diagram. gis.stackexchange.com/questions/54933/… provides a method for exploding a line at all of its vertices. Once you do that, carry out the steps outlined in my answer, then try using the GRASS function v.clean to re-build it into a topological network. NOTE: "Explode Lines" is now found under "Vector Geometry Tools"
    – wfgeo
    Commented Mar 26, 2018 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.