[GIS] Creating a line from two points in QGIS

qgis

I'm new to QGIS, and have what seems like basic requirements; however I'm struggling to find a solution. I have GPS data in excel showing start and end points of a boat survey. In a row, it has start x, start y, end x, end y.

I would like to plot these points on a map, and draw a line between each start and end point, but without drawing lines between points in different rows.

I've seen a few similar questions in the forums, but none of them seem to work when I try. Points to path seem to plot lines between rows, and only used one point per line, rather than the two required. I've also seen WKT mentioned, but I don't know how this works.

Best Answer

You might like the following process. Be aware it doesn't create a physical line layer in a different shapefile but a visual line layer from your data only visible within your QGIS project.

  • Load in your table data (via the Spreadsheet Layers plugin for example), and make the point geometry from the X and Y start column.
  • For the moment you will have your starting point data on screen.
  • Right click on the point layer and go to properties
  • Open the Style tab
  • Choose Single symbol, then geometry generator

Geometry generator

  • Choose LineString type in the list
  • Enter the following command, X_Start, Y_Start, X_End, Y_End being your 4 start and end fields :

    make_line( make_point( "X_Start","Y_Start"),make_point( "X_End","Y_End"))

Line generator

Instead of seeing point, you will see lines going from the starting point to the end point.