2

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?

  • If I join the two tables to one, then I have an attribute table with an starting point and an end point (x and y coordinates for each). Would it somehow be possible to calculate the difference (m) between the start and the end point with the field calculator? – Leni Jul 25 '16 at 9:02
2

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.

0

Try using a Distance matrix

Vector > Analysis Tools > Distance Matrix

QGIS Documentation: Distance matrix

  • I tried to use the distance matrix function, but I’m not able to select the ID field. Is there a setting I have to make before running it or why is this? It should be possible to select that, shouldn’t it? – Leni Jul 25 '16 at 8:19

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.