6

I'm currently using QGIS 2.17 to process map data and for drawing roads. I'm trying to add nodes whenever a road breaks, turns or starts/ends.

I've tried using the plugin "Locate points among lines" but it has one error : it adds a node to both a start and end of a road point instead of linking it with the next road point, which means I've got 1 extra node on each start and end of road to delete.

(A road "breaks" whenever it reaches an intersection/pedestrian crossing, and a new road linked directly with the previous road starts.)

Basically I want to do this: O-->O--------->O instead of this OO----->OO---------->OO

Is there a way to automate this process?

3
  • Hi, why don't you use the grass v.clean with the function rmdup to remove the duplicates nodes? If you don't have grass you can probably use the plugin geometry checker with a automatic rule to delete duplicate nodes.
    – Victor
    Sep 16, 2016 at 9:17
  • @Victor if he does that then the 'to and from' relationship in the nodes will not be maintained, he will have to cater for that as well. Sep 16, 2016 at 11:40
  • that's true but that's easily dealt with the field calculator since the topology is clean with something of the sort: attribute( get_feature( 'node_layer_name' , 'WKT_geom_field', geom_to_wkt(start_point($geometry))) , 'NodeId') and the same with end_point
    – Victor
    Sep 16, 2016 at 15:22

2 Answers 2

8

QGIS 3

Use the "Split with lines" tool from the Processing Toolbox (Ctrl+Alt+T).

qgis_3

QGIS 2

You can use "Split lines with lines tool" in QGIS from Vector overlay Tools > Split lines with lines to add node when two lines get connected together. The input line file can be the same file for input layer and split layer, as you can see below:

enter image description here

After running the "Split lines with lines" tool and use same file for input layer and split layer, as you can see below:

enter image description here

The output will be like this:

enter image description here

The "Split lines with lines" tool can be found in the Processing Toolbox:

qgis_2

3
  • Hi there, i'm assuming "to add node" means the add node function as the answer below after split lines with lines tool is used on my lines. I tried it but as my lines are already technically split (manual drawing line to line), it doesn't change anything as duplicate nodes are created still at an intersection when a line meets another line at a start and end. I've thought of a way though, if i am to join all the lines together on another layer and add nodes through there, will it work?
    – Fang
    Sep 19, 2016 at 1:42
  • @Fang split lines with lines tool works if the lines are not already split, otherwise it will create another nodes as you said. If you want to remove duplicate nodes, from Processing toolbox try to use "Delete duplicate geometries" or you can try "Remove duplicate points".
    – ahmadhanb
    Sep 19, 2016 at 4:45
  • Thanks for your help! I cant get the split lines with lines tool to create nodes but removing duplicate points helped.
    – Fang
    Sep 20, 2016 at 2:02
4
  1. You could use the "Extract vertices" tool can be found under Vector > Geometry Tools > Extract vertices or in the Processing Toolbox (Ctrl+Alt+T)

    Nodes

    This will create nodes at each vertex for each line feature.

  2. If some lines are spatially connected but not part of the same feature, using the tool above will create duplicate nodes. In which case, you can then run the "Delete duplicate geometries" tool for the Processing Toolbox to automatically remove these nodes.

4
  • 1
    Wouldn't duplicate nodes be created if some lines are connected (and not part of the same polyline)?
    – Victor
    Sep 16, 2016 at 16:52
  • 1
    You could always go back and remove the duplicates nodes. Sep 17, 2016 at 10:21
  • As Victor said, this does creates the same problem and leads back to my question. Removing duplicate nodes are somewhat complicated, I tried removing it through attributetable but can't manage to group by similar features (error) and i hope to find a simpler way to do it, perhaps by somehow connecting the lines first and then adding nodes.
    – Fang
    Sep 19, 2016 at 2:12
  • @Fang - Most welcome, glad it worked :)
    – Joseph
    Sep 20, 2016 at 9:32

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.