QGIS has only one real geometry per feature. To get around this, the easiest way is to use the Geometry Generator.
Import the CSV using origin_laty
and origin_lonx
as the X and Y geometry columns. Your layer will now show the origin point. You can style it in the symbology settings as you wish.
Now add a new symbol layer in the symbology, and make the symbol layer type be Geometry Generator, geometry type LineString. In the expression window (where it probably just says $geometry
as a default), enter
make_line( $geometry ,
make_point( "destination_lonx" , "destination_laty" ) )
Go ahead and style this line symbol layer to show the connecting line.
Finally, if you wish, add a 2nd Geometry Generator symbol layer, of point type, with just the expression
make_point( "destination_lonx" , "destination_laty" )
To display the destinations.
If you felt like it, you could create a virtual field Destination
in the field list using the Field Calculator, and use the make_point(...)
expression to populate it, and then use it as an attribute in the above 2 symbol layers. This saves it being recalculated twice, and you could use it for other purposes too, but for a simple CSV layer is hardly worth the effort.
Editing to add: I see J.R answered in line with my answer while I was typing it. Keeping mine up since I explicitly wrote out the expressions, just in case that's useful.
Additional option. If the visibility issues J.R. mentions (and I've experienced too...) become a concern, you could also preprocess the CSV in Excel (or wherever) and create another calculated column there with the connecting line in WKT. See my answer at Creating multiple separate vector lines from list of coordinate pairs in QGIS