[GIS] Calculating distance between two points with QGIS 2.14.0

distancepointqgis

I have two shapefiles with the following information:

  • List A:
    ID 1 | xA | yA | ID 2

  • List B:
    ID 1 | xB | yB | ID 2

{x;y} = {lat;lon}

I want to calculate the distance between two points, e.g. ID 1: distance from {xA,yA} to {xB,yB}.

The KBS is WGS 84 and I need the result in meters. Can anyone tell me how to do that?

Best Answer

First merge your two shapefiles into one (copy/paste all your points from one to the other, or use the tool Merge Shapefiles to one... in Vector > Data Management Tools). Check that all your points have their ID in one unique field.

Next go to Processing > Toolbox. In the toolbox windows, search Convert points to line(s) and open it. Select your shape in the Points field, and select your ID in Order by... and Separate by..., give a name to your new layer and click Run.

Now, all your points that have the same ID should be joined together by a line. You can now generate the length of all lines with the Field Calculator.

If lengths seems to be false, convert your line shape from WGS84 to an other CRS that use the meter for unit.

Related Question