I am using QGIS 2.14 and I have a list of distances and descriptions similar to the table below

pipe2,51,break in pipe

I would like to add a point along a pipe at the specified distance (eg. 50,100,51) . I know there is a processing algorithm but I don't think I can use it with selected lines.

How can I add points along a line using my table?

3 Answers 3


One workaround by using PyQGIS is in the next code. I put your original distances in a list but, it was assumed that each point should be placed in positions along the line based in a sum_distances list ([50, 150, 201]).

registry = QgsMapLayerRegistry.instance()

layer = registry.mapLayersByName('my_line2')

distances = [50, 100, 51]

sum = 0

sum_distances = []

for dist in distances:
    sum += dist

feat = layer[0].getFeatures().next()

geom_points = [feat.geometry().interpolate(distance).exportToWkt()
               for distance in sum_distances]

epsg = layer[0].crs().postgisSrid()

uri = "Point?crs=epsg:" + str(epsg) + "&field=id:integer""&index=yes"

mem_layer = QgsVectorLayer(uri,

prov = mem_layer.dataProvider()

feats = [ QgsFeature() for i in range(len(sum_distances)) ]

for i, feat in enumerate(feats):



After running the code at the Python Console of QGIS I got:

enter image description here

It seems to work correctly.

  • The distances are not a total. The first column in the table is a pipe ID. If the feature attribute matches the ID then start adding the points along those matching lines (pipes). You answer gave me a starting point.
    – GreyHippo
    Commented Mar 14, 2017 at 19:58

You can get this with the interpolate function in PyQGIS.

I manually tested this with a multilinestring layer.

  1. Open the python console Plugins -> Python Console
  2. Select the layer you want to place points on, and select the linestring feature you want to place a point on
  3. In the Python console do the following commands

lineLayer = iface.activeLayer() lineLayer now represents the layer you have selected

line = lineLayer.selectedFeatures()[0] line now represents the first feature selected on your line layer. Make sure you only have one feature selected

feature = QgsFeature() creates a new feature

point = line.geometry().interpolate([distance along line]) point represents the geometry of the point at the specified distance along your line feature

feature.setGeometry(point) sets the geometry of the feature

  1. Create a new multipoint layer and select that layer in the layers panel and then do the following commands.

pointLayer = iface.activeLayer() pointLayer is now the multipoint layer just created.

pointLayer.addFeature(feature) add the point feature you created with interpolate to the new layer.

Notes: The distance used in interpolate is based on the coordinate reference system that you are using. Make sure it is a projected CRS with appropriate feet or meters conversions to match the distances you want to offset. Test to make sure the distances are correct before doing too much.

With this general pattern you should be able to set up a simple script in python to create all of the points from your offsets.


With the help of the answers in this post I wrote a Qgis python plugin to accomplish my needs. I use it for processing CCTV data from sanitary sewer work. The plugin accepts the following CSV file

Pipe ID,Location,Start Manhole,End Manhole,total_pipe_length,Surveyed Length,Pipe Diameter,Pipe Material,Direction,Distance,Code,Description,Clock,Lateral Size,Grade,Comment
P4171,somewhere,A34,A33,210.7,210.7,8,RPM,Downstream,63.8,tsc,tap saddle capped,12:00,6 inch,M0,cast iron cap
P4171,somewhere,A34,A33,210.7,210.7,8,RPM,Downstream,142.8,tsd,tap saddle defective,11:00,6 inch,M2,reinforcement exposed
P4176,somewhere,a30,a31,129,129,8,RPM,Upstream,53.5,tsa,tap saddle active,11:00,6 inch,M0,light flow
P4176,somewhere,a30,a31,129,129,8,RPM,Upstream,57.7,tsc,tasp saddle capped,11:00,6 inch,M0,nothing
P4176,somewhere,a30,a31,129,129,8,RPM,Upstream,102.8,tfa,tap factory active,11:00,6 inch,mo,light flow
P4595,somewhere,A31,A31A CAP,13,13,8,RPM,Upstream,8.9,tsa,tap saddle active,10:00,6 inch,M0,light flow
P4179,somewhere,A23A,A23,79.2,79.2,8,PVC,Downstream,13.2,tfa,tap factory active,1:00,6 inch,M0,nothing
P4182,somewhere,a21,a22,226.6,226.6,8,pvc,Upstream,65.3,tsa,tap saddle active,11:00,6 inch,m0,heavy flow
P4182,somewhere,a21,a22,226.6,226.6,8,pvc,Upstream,85.7,tsa,tap saddle active,11:00,6 inch,m0,nothing
P4182,somewhere,a21,a22,226.6,226.6,8,pvc,Upstream,198.2,tsa,tap saddle active,11:00,6 inch,m0,nothing

The plugin can be downloaded from the typical plugin location within QGIS. The plugin home page is https://github.com/boesiii/CCTVMapper

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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