I would like to create a specific amount of points along a line in QGIS. The lines are in different lengths, but I want them with a maximum of 50 points (divide by 50). The tools i've found in QGIS are able to place points in a specific distance along a line or geometry.
2 Answers
You can create points with Geometry generator or Geometry by expression (see here how to do that) using this expression. In line 3, change 20
to set the number of points you want to create per line:
with_variable (
'no',
20,
collect_geometries (
array_foreach (
generate_series (0,@no-1,1),
line_interpolate_point(
$geometry,
length($geometry) / @no * @element
+ length($geometry) / @no / 2
))))
Points are distributed evenly along each line with the same distance from start- and end-point of the line. Delete the second last line (from +
to 2
) to get the first point on the start-point of the line.
Screenshot, showing the variant using Geometry generator - create 20 points per line: