In QGIS 3.22 I have two point layers named:
- 'source_p'
- 'target_p'
I want to point automatically with a line from the 'source_p' layer to the two nearest points on the 'target_p' layer.
Manually, I was able to generate such code where the 'target_p' layer refers to the "parent"
field in the 'source_p' layer.
make_line(
$geometry ,
geometry(
get_feature('target_p', 'fid', parent)
)
)
join attributes by nearest
adding the 2 closests points on your target layer to your source layer, then create the lines.