# Find item from start point and end point of line

I'm working on a project that wants me to find the names of items at the start and end of a line.

I have a point at each end of a line, these points all have a name. I would like to get the name of this point and populate a field called source with the name of the point and then repeat this for the end of the line with the field target.

Is it possible to do some kind of geospatial analysis to get this information?

• Check the answers to this question, the problem is very similar to yours: gis.stackexchange.com/questions/325464/…
– Erik
Sep 17, 2021 at 10:15
• "Is it possible?" questions pretty much all have the same answer: "Sure, it's possible! What have you tried? What problem have you encountered?" We use a Focused question/Best answer model. Since "get the name at the start point" is the same basic problem as "get the name at the end point" this becomes five problems (all easily accomplished with any GIS): "Find the start point of a line", "find the end point of a line", "with a point, find a nearby feature in another layer", "with a feature, retrieve a property", and "update a field for a feature". Each of these is already answered here. Sep 17, 2021 at 10:43

On the line layer, create a new field with field calclulator and the following expression for the start-point. The expression creates a buffer around the start-point of the line, then looks for the two closest points to the line and checks which one lies inside the buffer. From this point, it takes the value of the field `name`.

Adapt the expression as follows if necessary:

• For the end-point, simply replace `start_point` (line 8) with `end_point`
• Replace `points` with the name of your point layer and `name` with the field-name you want to get.
• Only in case it doesn't work as expected: Change the value of `0.001` at the end of line 8. This is the size of the buffer around the start-point of the line and the expression checks which of the points is within this buffer.
• Only in case you you have several points on your line (not just start- and end-point): increase the value at end of line 4 (now: `2`) to the max. number of points that are on a line.
``````array_first(
array_remove_all(
array_foreach (
overlay_nearest ('points',\$id, limit:=2),
if (
within (
geometry (get_feature_by_id ('points',@element)),
buffer (start_point(\$geometry), 0.001)
),
attribute (get_feature_by_id ('points',@element), 'name'),
''
)),
''
))
``````

Get the value of the point layer's `name` attribute of the point that lies on the start- and end-point of the line as an attribute on the line layer. Here the expression is used in a combination as a dynamically created label of the line: 