# Localization of a point on a line in QGIS [closed]

I'm relatively new to the GIS field. I have several polylines (streets) and would like to locate stations on these lines. The start and end points of the lines, the length of the line and the distance of the stations from the starting point are given. I'm looking for the coordinates for the stations. With GRASS and PostGIS there are probably possibilities. Does anyone have good explanations?

## closed as too broad by LaughU, radouxju, whyzar, jbalk, Jochen SchwarzeJan 31 at 7:27

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

In QGIS Built-in functions (I think since the 3.0 version), it is a function for do what you want :

fonction line_interpolate_point

Returns the point interpolated by a specified distance along a linestring geometry.

Syntax

line_interpolate_point(geometry, distance)

Arguments

geometry : a linestring geometry

distance : distance along line to interpolate

Examples

``````geom_to_wkt(line_interpolate_point(geometry:=geom_from_wkt('LineString(0
0, 10 0)'),distance:=5)) → 'Point (5 0)'
``````

In your case, add two real fields (one for x_coords, and one for y_coords) to the line layer, go to the field Calculator and for update the `x_coord` field with :

``````x(line_interpolate_point(\$geometry, "station_distance_field"))
``````

and `y_coord` field :

``````y(line_interpolate_point(\$geometry, "station_distance_field"))
``````

With PostGIS, I think the result can be found with the function ST_LineInterpolatePoint.

The first argument is a line / polyline geometry and the second one, the fraction of total linestring length from the start point. If you have the distance of the station and the length of the line (cf. ST_Length), you can have the second argument.

EDIT

Based on your comment, and for example, open a python console and run in the editor the following code, creating a memory line layer with 3 features :

``````vl = QgsVectorLayer("linestring?crs=EPSG:3044\
&field=route_name:string(50)\
&field=length:integer\
&field=Startingpoint:string(70)\
&field=Endpoint:string(70)\
&field=Distance:int8",
"line_layer",
"memory")

pr = vl.dataProvider()
ft = QgsFeature()

ft.setGeometry(QgsGeometry.fromWkt("LineString (753979 5779912, 729900 5699907, 687178 5651749, 675527 5640874)"))
ft.setAttributes(['route_1', 163829, '', '', 50])

ft.setGeometry(QgsGeometry.fromWkt("LineString (450270 5842052, 519401 5861471, 641350 5824964, 651448 5802438, 650671 5741075, 583871 5657186, 447940 5664177)"))
ft.setAttributes(['route_2', 528657,'', '', 100])

ft.setGeometry(QgsGeometry.fromWkt("LineString (416093 5581065, 541927 5580288, 598629 5535237, 622708 5466106, 632029 5428822, 693392 5395422, 725239 5400083)"))
ft.setAttributes(['route_3', 412041, '', '', 200])
• Can you test the code I've added in the post and tell if the functions work ? I use `x(line_interpolate_point(\$geometry, "Distance"))` and it's work perfectly. – J. Monticolo Jan 31 at 9:57