4

I need to add the missing vertex of two lines intersection places using QGIS.If any default plugins or tools available for fixing missing vertex in qgis,kindly suggest me.

My Inputs:

enter image description here

enter image description here

In above screenshot one line feature having vertex on highlighted area and another one line has no vertex on that place.I need to place missing vertex on one line.

2

To add a vertex you need to select the feature you want the vertex added to. Then activate vertex tool: highlighted in yellow

When hovering with your mouse over your selected line you will see a small plus sign between two verticies. Click on that to add a new vertex, and drag & drop that new vertex to the existing one of the other (not selected) line. With snapping enabled (by pressing s) the to verticies will be perfectly aligned!

enter image description here

Edit: As requested in the comments, to add verticies to all lines placed ontop of each other you have to enable topological editing:

enter image description here

Then select all the lines you want to add the new vertex to and follow above description (hover over the line segment, click the little plus sign which should appear and drag & drop the vertex to the existing one)

| improve this answer | |
  • Hi,I need to add the vertex for more number of feature without manual vertex adding of each and every features. – Raja Aug 6 at 14:08
  • then please add this information to your question, this is not what you originally asked – sn1ks Aug 6 at 14:19
0

Yes, that's possible with the QGIS API, namely with QgsVectorLayerEditUtils.addTopologicalPoints().

Result:

enter image description here

Ready-to-use code snippet (adapted from here):

# Preparation
index = QgsSpatialIndex(layer)  # Optimize intersection checks
edit_layer = QgsVectorLayerEditUtils(layer)
request = QgsFeatureRequest().setNoAttributes()  # Get rid of attributes
dict_features = {feature.id():feature for feature in layer.getFeatures(request)}

with edit(layer):
    for fid, feature in dict_features.items():
        bbox = feature.geometry().boundingBox()
        candidate_ids = index.intersects(bbox)

        # Get rid of intersections with itself
        candidate_features = [dict_features[candidate_id] for candidate_id in candidate_ids
                              if candidate_id != fid]

        for candidate_feature in candidate_features:
            # Add missing vertices from candidate_feature to intersecting features
            edit_layer.addTopologicalPoints(candidate_feature.geometry())

Note: If your lines are in different layers, you can use the external code I mentioned above, which I took as reference.

| improve this answer | |

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.