0

For network consistency issues every polyline in layer A must have a point in layer B at start and end nodes.

Lately we've realized our network editors usually forget to add this points to layer B so I'm looking for a way to automatically create this points every time a new polyline is drawn, but checking first if there's no point at the polyline start or end nodes.

Is there any way of doing this using QGIS?

Generally each editor edits their own files: several point, polyline and polygon shapefiles or a single geopackage. There's a small number of editors working with data in Oracle but I want to focus on the easier scenario first.

Editors create or modify polylines when they need to. There's no exact frequency. Maybe once or several times a day or maybe once a week/month.

The workflow should be:

  • Create or modify a polyline
  • If a new polyline is created, create a point at its start and end nodes if they are missing. (If a new polyline is snapped to an existing one that one should already have points at its nodes so that should be checked.)
  • If an existing polyline is modified and the start or end nodes are moved, the related points should be moved too.
  • New points should get the new polyline unique id in an attribute field.
  • Edit other related layers.

It's important that points are created right after the end node of the new polyline is created because the order points are created is important (the unique id of points help us track the order they were created).

  • 2
    I think some more details on your or your editors workflow when creating/checking the lines would be useful. Are several people editing this file? Is it one or several files? Is it consolidated on a daily base? When do you need the points to be created? etc. – Erik Jul 16 at 12:44
1

edit: following updates from OP, my answer is inadequate. I'll leave it up as a reference though.

initial: We are missing specifics on the workflow, but the easiest way that comes to mind is to let the editors digitize then once a day run a small model on the network layer to check if any nodes were missed. In order to create the geometries (you haven't specified if a series of attributes need to be added to the nodes and that's another can of worms), something like this would work:

  • Select by location tool
    • Select features from: your line layer
    • Geometric predicate: disjoint
    • Compared to: your nodes layer

Then with the lines selected:

  • Extract specific vertices tool
    • Input layer: your line layer
    • Check Selected features only
    • Vextex indices: 0, -1

This will create a new layer and add the start and end vertices on every line feature that didn't touch another node. There will be duplicate points where start and end points overlap so you can run the Remove duplicate vertices tool on your new points layer to solve this. You'll then have to merge the new points with your original node layer and add any attributes yourself but at least you'll have geometries already created.

  • I need this to be done every time a new polyline is created so this should be automatic. I've been checking the Attributes Form Defaults section to see if there's a way of indirectly creating the points using an expression to calculate any attribute for the new polyline. No idea if this is the way to go. – DMS02 Jul 17 at 7:18
  • @DMS02 Right. This is much more complex and would require scripting. It's outside of my comfort zone, I'm not very quick with pyQGIS. – Gabriel C. Jul 17 at 13:28

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