For an examination of a local power grid, I need to mark the transformation stations (substation) by simply create a point for each station.

What I want to do is that QGIS creates a point at the end of a line automatically.

How can I get there?



Tested on QGIS 2.18 and QGIS 3.4

I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer...

Let's assume there is a polyline layer called "polylines" (blue lines).


With the following Query, it is possible to create a point at the end of each line.

SELECT st_endpoint(geometry), *
FROM "polylines"

The output point layer (yellow) with its attribute table will look like


Mind the difference between ST_EndPoint and ST_StartPoint. Basically, what @TeddyTedTed meant by Which one you need will depend on the direction of the line.

Additionally, I may suggest using Python code from this article. Achieved from @Joseph's answer

line_layer = qgis.utils.iface.activeLayer()
feat = QgsFeature()

point_layer = QgsVectorLayer("Point?crs=epsg:31469", "point", "memory")
pr = point_layer.dataProvider()

for feature in line_layer.getFeatures():
    geom = feature.geometry().asPolyline()
    end_point = QgsPoint(geom[-1])

| improve this answer | |

In the Processing Toolbox use the Extract Specific Vertices tool, for the Vertex indices use 0 for the first vertex and -1 for the last vertex. Which one you need will depend on the direction of the line.

EDIT: Apologies, I didn't read your question properly, you said automatically. If it's just for display purposed you could use a geometry generator symbology to show a point at the end of the line using end_point($geometry) as the expression. If you need to create an actual data point automatically every time a line is created then I'm not sure how to do that.

| improve this answer | |

A simple solution could be:

Using Vector ‣ Geometry Tools ‣ Extract verticas. Afterwards simply delete all points but thoose which were generated at the end and beginning.

| 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.