This question is almost identical to my previous question. However, instead of placing a point at each vertex, I would like to place a point at a specified distance from each vertex (start offset, end offset)
For example, I would like 36 points along a group of lines, each with slightly different lengths. The start point and end point is 1.5 feet inward from each line vertex.
I tried using the Points Along Geometry
tool. With the Distance
field set to and also $length/37
and the Start Offset
and End Offset
set to 1.5
. All also tried with the Distance
set to ($length/37)-0.0001
.
I tried Geometry by Expression
with the expression..
collect_geometries( array_foreach( generate_series(1.5, $length-1.5, $length/37-0.0001), line_interpolate_point( $geometry, @element)))
..but was not able to achieve the desired results.
Best Answer
There are two problems in your approach:
$length
calculates ellipsoidal distances. So you might want to uselength($geometry)
to get planimetric distances. Depending on what CRS you use and what distances you have, that might play a role or not.Generate a series from 0 to 35 (36 points) and multiply this with the interval. Be aware: there are 35 intervals for 36 points. So the length of the interval is: line's length minus 3 (for 1.5 offset at start and end), divided by 35. Then add to this the start offset of 1.5 and multiply the
@element
for each point with the interval.This is the expression to use:
Demonstration for 26 points and offset of 15 from start-/endpoints:
Variant:
To easily change the no. of points and the offset, use variables.Change the values of
36
and1.5
on lines 1 and 2 and the expression will automatically adapt: