I have a point layer and need to draw a line passing through or in the vicinity of the points (up to 0.5m distance between the point and the line). The nodes of the line will receive the attributes of the points closest to them.
The simplest way is to use the points to create the line. To do this in QGIS use the Points2One plugin. Install this plugin (available via
Plugins > Manage and install plugins) and follow the dialog to create a line from your points.
If you have multiple lines, then make sure your points data has a suitable ID field to identify the lines they belong to.
Alternatively you can use
v.build.polylines in GRASS (available through QGIS) or the SAGA GIS tool
Convert points to line(s) Available through the Processing Toolbox (Ctrl+Shift+T).
In QGIS 3.x instead of the plugin mentioned above, you can find the "Points to path" tool in your Processing Toolbox (Ctrl+Shift+T). Works exactly the same...
One way to do this would be using a "Virtual Layer".
"Y"fields in your point layer containing the x and y coordinates
- Create a constant field with the same value
- Save a copy of the point layer
- Add a virtual layer joining by the constant value of both layers (original and copy) using the following expression:
SELECT * FROM points JOIN points_copy ON points.constant = points_copy.constant
This will create a Virtual Layer that will contain every combination of X,Y origin and destination coordinates. In my example I used 29 points thus resulting in a virtual layer of 841 points (29²).
Just for symbolization purposes the point layer can be symbolized into lines using a geometry generator expression:
make_line(make_point("cx", "cy"), make_point("cx:1", "cy:1"))
To make a permanent layer I recommend using the tool XY to line from the plugin Shape Tools.
In this particular case the OP asked to limit the distance to 0.5 m which can be accomplished filtering the lines by length.