I want to make a buffer on the start or end point of the line and not the line itself.
Is there some thing in QGIS python plugin development that can get me the points?
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
You can use v.to.points Processing Toolbox Algorithm.
At the next image, it can be observed:
After click in Run, I got "start and end points of each feature" in the shapefile line layer.
However, by using 'Write line vertices' option you can get all points:
You can use the following code to get the start and end points of your line layer and loads this as a memory point layer:
line_layer = qgis.utils.iface.activeLayer() feat = QgsFeature() point_layer = QgsVectorLayer("Point?crs=epsg:4326", "point_layer", "memory") pr = point_layer.dataProvider() for feature in line_layer.getFeatures(): geom = feature.geometry().asPolyline() start_point = QgsPoint(geom) end_point = QgsPoint(geom[-1]) feat.setGeometry(QgsGeometry.fromPoint(start_point)) pr.addFeatures([feat]) feat.setGeometry(QgsGeometry.fromPoint(end_point)) pr.addFeatures([feat]) QgsMapLayerRegistry.instance().addMapLayer(point_layer)
You can then use this memory layer to create buffers around the points.
layer # your vector layer (line type) for feature in layer.getFeatures(): geom = feature.geometry().asPolyline() print "Start: " + geom print "End: " + geom[-1]