I have a linear network of lines all digitized in the direction of flow and am trying to assign route ID's to segment groups. Is there an automated process to do this using QGIS?

  • in the Processing Toolbox there's multipart to singlepart – csk Aug 2 '19 at 17:51
  • That was my first thought; dissolve and single part the output but all it seems to do is undo the dissolve. I end up with the same number of features as I started with. I just need a tool, or set of tools, or a tutorial to setup route ids without doing it all manually. The features are digitized in the direction of the flow. – Tyler Veinot Aug 3 '19 at 20:54
  • What are the common attributes? It should be possible to do this with the Field Calculator. – csk Aug 4 '19 at 13:31
  • Size, Material, Street, Feature Code, Year, Enabled, Active, etc... – Tyler Veinot Aug 13 '19 at 11:04

Use the Field Calculator to create a new field (the group ID field) with an expression like this:

CASE WHEN "common_attribute" = 'value1' THEN 'group1'
     WHEN "common_attribute" = 'value2' THEN 'group2'
     WHEN "common_attribute" = 'value3' THEN 'group3'
     WHEN "common_attribute" = 'value4' THEN 'group4'
     ELSE null

Repeat the WHEN...THEN section as many times as you have groups.

If each group has a combination of conditions, join them using the AND operator, like this:

WHEN "common_attribute1" = 'value1' AND "common_attribute2" = 'value2' THEN 'group1'
| improve this answer | |
  • This basically worked but it is time consuming because where routes cross streets or where street names change I end up with a new route ID. On streets like Cul--de-Sacs and crescents it doesn't generate the ID improperly. Is there a way I can use line azimuth as a factor so that the ID will tend to follow lines with similar azimuths? Or is it just something I am going to either have to do manually or pay for a network analyst license from Esri? – Tyler Veinot Aug 19 '19 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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