I am working with two shapefile layers: lines and points. These shapefiles do not overlap and have different attribute values.
The point layer contains data that I want to join to the beginning and end of the line layer. If a canĀ“t join this data by field value or location, which vector tool should I use in QGIS?
Best Answer
I can suggest using a "Virtual Layer" through
Layer > Add Layer > Add/Edit Virtual Layer...
.Let's assume we have the following layers 'Layer_Points' and 'Layer_Lines', see image below. The data that has to be transferred from the points placed in the field
"Data"
.With the following query, it is possible to join points' attributes to lines appropriated through the beginning and the end of the line layer.
The output Virtual Layer with its Attribute table will look as following
ST_ShortestLine()
is the shortest line between two geometries.ST_StartPoint()
defines the lines' starting points for connecting with points layer, see image below.The same principle was applied for
ST_EndPoint()