# Generating points along line with specifying the origin of point generation in QGIS

I have been trying to generate points along a line with a distance of 500m. We can do this in several ways using tools like "Points along Geometry". However, my problem is that I do not know how to generate points in a specific direction along the line.

I tried using "Points along Geometry", but there is no option to specify the origin. Below you can see what I get using "Points along Geometry".

The problem is that the generation is going down to up and I want it up to down. Is it possible to choose the origin of the line to start generating points?

.

The tool `Points along Geometry` follows line direction and thus begins where the line has the first vertex (start point). To start from the other end (the last vertex, end point), reverse the line direction:

Use Menu Processing > Toolbox > Reverse line direction, then create the points on the resulting line.

You can create a Virtual Layer using functions `ST_Line_Interpolate_Equidistant_Points` and `ST_Reverse`

Replace `road` with the name of your layer.

To get the point starting from line starts:

``````SELECT row_number() over() as id, ST_Line_Interpolate_Equidistant_Points(geometry, 500.0) as geometry
``````

To start from the line ends, reverse it:

``````SELECT row_number() over() as id, ST_Line_Interpolate_Equidistant_Points(St_Reverse(geometry), 500.0) as geometry
``````

You will get a multipoint output. You can convert them to single parts with "Multipart To Singleparts"

Use the following expression to create points at a regular interval along a line. Set the interval distance in line 1 (in my example: `80`). Line 2 is for the option you're looking for, "specify the origin": change `0` to `1` to start the creation of the points from the other side (starting from the line's end point). For this, I used the function `reverse()`, together with an `if()` clause (line 7).

Use the expression with Geometry Generator (for visual purpose/testing the result in realtime) or Geoemtry by Expression (for actual geometries) - see here for details.

By the way: if you want to add a start offset, in line 6 simply replace `0` by the distance you want the first point to offset. For end offset, in the same line add `-100` (or whatever distance) directly after length(\$geometry) - before the comma.

``````with_variable ('interval',80,  -- distance between points
with_variable ('direction',1,  -- set to 1 to reverse line direction (start creating points from the line's opposite end)
collect_geometries (
array_foreach(
generate_series (0, length(\$geometry),@interval),
line_interpolate_point (
if(@direction=0,\$geometry,reverse(\$geometry)),
@element)
)
)
))
``````

The expression, used here with Geometry Generator; lines start at the left, but points are being created starting from the right because in line 2, tha variable `@direction` is set to `1`: