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?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
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
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]) feat.setGeometry(QgsGeometry.fromPoint(end_point)) pr.addFeatures([feat]) QgsMapLayerRegistry.instance().addMapLayer(point_layer)
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.