QGIS – How to Generate Lines from Origin to Destination Points

qgis

I would like to generate lines from origin to destination points as illustrated below.
In this example, ID is a unique ID of each point and used as origin whereas Dest is used as destination from ID.

enter image description here

I found some posts which related to my question but it cannot directly solve my issue.

Workflow for creating line features between two coordinate pairs in QGIS

Creating lines from starting to arrival points?

QGIS: writting an expression in geometry generator for a straight line with given azimuth

I think the third post using Geometry by expression tool seems to be the one which solve my issue but I am not sure how to draw line from start to end points.

I do not need to use geometry generator if other solutions are easier and faster.

Best Answer

Easiest is probably using QGIS expressions with Geometry generator (for visualization only) or Geometry by expressions (to create actual geomtries) (see here for details on both options) with this expression:

make_line (
    $geometry ,
    geometry (get_feature (@layer, 'ID', "DEST"))
)

Using Geomtry by expression, you must repace the variable @layer with the name of the points layer in single quotes, e.g. 'points' Form a layer named points.

enter image description here