I'm trying to add points along lines every 3 metres but I'd like the starting/ending point at certain non fixed distance. When I use the tool 'Points along geometry' inside Graphical Modeler. I don't want a fixed distance for 'start/end offset", the distance is variable. I want to use a field called "offset" containing the pre-calculated distance for every line.
When I select the column "offset" with the distances in it, QGIS doesn't recognise or ignores the values. Instead of adding points at the predefined value, It's adding the double of distance at the starting point and adding the endpoint at the end of the line which I don't want.
Am I missing something?
Is there any other way to do this?
With QGIS or PyQGIS?
Any ideas?
As far as I can see, there is no option to use this tool above to solve my problem. Someone suggested using Python within QGIS. I'm a beginner so I'm not quite confident about the code. I only have a few lines but I know that it needs to add a lot more.
I have a layer with lines and I want to add points along the lines with 3 metres equidistant. In addition, I have a column on the attribute table with the distances for start and end offset for each line which I would like to use.
What I have:
from qgis.core import (QgsFeature, QgsGeometry, QgsVectorLayer, QgsMapLayerRegistry, QgsField)
inputLayer = iface.activeLayer()
feat = layer[0].getFeatures().next()
for feat in inputLayer.getFeatures():
dist = feat['offset'] # this is the field name with distances
geom = feat.geometry()
l = 0
while l < geom.length():
p = geom.interpolate(l)
print(p)
l += dist







