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.

  • With snapping, it's very easy to digitize a straight line between two points. Is there some reason that doesn't meet your needs? – csk Aug 14 '18 at 20:19
  • Thanks for your answer !, I'm pretty new to QGIS so would you please tell me exactly how should I do this ? – nima miryeganeh Aug 14 '18 at 20:40

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.

  • One more question !, I added the line layer with two fields ("source" and "dest"), Now is there anyway that when I "add line feature" to connect two points, it can automatically fill those two fields with the "name" of those two point ? (I've added a picture to my post to explain better) – nima miryeganeh Aug 14 '18 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.