I have two layers both containing points - each point in the first layer has a corresponding point in the second layer (same primary key). One layer has CRS EPSG:27700 and the other layer has EPSG:4326. Project CRS is EPSG:27700.
I want to calculate the distance between each pair of points. I tried the Distance Matrix, however the distances returned were nothing like those returned by Measure Line (which I used as a check).
I then tried using the field calculator, with the expression:
distance($geometry,geometry(getFeature('LAYER2','KEY', "KEY" )))
However again the values are much too big, e.g. for one pair of points:
Measure Line give 99.654m; distance gives 849950.964330714.
I wondered if the problem related to the different coordinate systems, so I saved the EPSG:4326 layer as a shapefile with CRS EPSG:27700. This time
distance() returns sensible results, e.g. for same pair of points:
Measure Line give 99.654m; distance gives 99.6801982600587.
For a given project CRS, shouldn't
distance() give the same results irrespective of the coordinate systems of the individual layers?