QGIS Connection – How to Connect Points in Two Layers Using Lines in QGIS 3.x

connectionlineqgisqgis-3

enter image description hereI'm using QGIS 3.2.1 and I have two Layers containing point objects, Is there any plugin for this version of qgis that I can use to select two points and then connect them using a line and save the line in a separate layer? I think I'm searching for something like ReconstructLine, But apparently it's not compatible with this version of qgis.

Best Answer

Digitizing a straight line between two points using snapping

Create a new layer

Skip this step if you already have a layer to which you want to add lines.

Layer menu > create layer > New Shapefile Layer... (or geopackage or spatialite, whichever format you prefer)

  • Click the ... button, choose a folder and type a name for your new shapefile.
  • Choose "line" from the dropdown for Geometry Type.
  • Choose a CRS. If you're not sure, go with the same CRS as the point layers.

enter image description here

Once you click OK, the shapefile will be created and automatically added to the project.

Use the Snapping Toolbar to set up snapping

  • Enable snapping for all layers
  • Snapping to vertices
  • Snapping tolerance: 10 px or so

For a detailed explanation of how snapping works, see the answer to Unable to snap vertices and segment in QGIS 3.0.

Digitize a line between points

Turn on editing for the new line layer you created. (Select the line layer in the layer panel, then click the yellow pencil button in the Editing toolbar. Once editing is enabled, a yellow pencil icon will appear next to the layer name.)

enter image description here

Click the "new feature" button in the editing toolbar.

enter image description here

Click on the first point, then the second point, then right-click to finish digitizing. Click OK on the attribute window. (With snapping enabled, your mouse automatically snaps to each of these points, so you don't have to be very precise with where you click.)

Now you have a line between the two points. Repeat as needed. Save your shapefile by clicking the save layer button on the editing toolbar. Note that this is not the same as the "save project" button on the project toolbar.

enter image description here

Note: When the layer has unsaved edits, the pencil next to the layer name turns orange, and an orange pencil appears on the save layer button.