3

My guess is that I'm doing something wrong with QGIS, but here goes.

I have multiple point data layers in WGS84, mostly of UK locations, but with point in Canada, South Africa and New Zealand. I also have line data generated from the point data with MMQGIS/Hub Lines. What I need are accurate distances (line lengths) for the Hub Lines. I have tried this in QGIS 2.12.2 in Windows 32-bit, and in 2.16.1 in Kubuntu 64-bit. The processor is an AMD A-series quad-core, and 8GB RAM.

First, I have remembered to change to an equidistant projection to correct the distortion in WGS84, and have tried using On the Fly re-projection, and simply starting a new project with minimal point and line data all converted to, for example, World Azimuthal Equidistant, but I am getting severe errors. To simplify my explanation I have also tried the QGIS tutorial on calculating line lengths here: http://www.qgistutorials.com/en/docs/calculating_line_lengths.html

Following these tutorial instructions gives me a result for uident: 1506 (first line of attribute table) of 0.01 km; most other entries are 0.00 km. The correct result appears to be 637.07 km. If I calculate another column from this data in meters, without the division by 1000, the same entry shows the line to be 8.40 m in length. Further, if I load a Natural Earth country boundaries map to this project and re-project, the line measurement tool shows the whole of mainland USA (excluding Alaska) to be roughly 50 km east-west, and 25 km north-south. I am getting similarly wild results in my own data.

What have I got wrong?

EDIT: Turning Linux off and turning it back on again has cured the issue in the tutorial mentioned above; but why? And why do I still have the error in my own data? In the latter the distance from Bristol, UK to Auckland, New Zealand is calculated at 0.154 km, and the measuring tool shows the same.

I am still getting something wrong. If I now add the Natural Earth world coastline layer to the project with On the Fly project active, all my point and line data shrinks into a spot at coordinate 0,0.

2

If you want to get correct distances on a worldwide scale, you need an azimuthal equidistant projection centered on the start or destination point. See great circles in QGIS and export in 3857 webmap for an example.

A line drawn in WGS84 is not the shortest path, you need the Great circle line between your points. And you have to reproject the data into a projected CRS. Otherwise you get distances in degrees, not meters.

Most probably you have used Set Layer CRS instead of reprojecting the data with Save As ... to a new filename and different CRS.

  • Thanks - explored the link but I'm obviously not following something correctly because I still have errors of about +15%. I do have a minor problem with my data in that I have 33 records with 20+ source/starting points and 33 end points, and I don't really want to create 20 custom CRSs. Most of the starting points are in the same city, and I can accept a small level of inaccuracy given that I am expecting line lengths of between 0.02 km and ~20,000 km, but 15% is too inaccurate to be usable. – NickN Sep 20 '16 at 19:49
  • Inaccuracy against what source? Keep in mind that the Earth is not flat, so planar geometry returns false distances. – AndreJ Sep 21 '16 at 5:17
  • My mistake: comment on inaccuracy is inaccurate, it's more than close enough. The one thing I am left with, and it's only a visual thing, is that my lines in the custom CRS become nice arcs when I densify the lines, but when I re-project the whole back to WGS84, they are virtually straight -- maybe that's the nature of my data, but the 'great circles' example has similar points created from a similar custom CRS 'center'. – NickN Sep 21 '16 at 8:42
  • It should be the other way round: In the custom CRS, the shortest ways should be a straight lines, after densifying and reprojecting to WGS84 they should be curves. – AndreJ Sep 21 '16 at 14:18
  • AndreJ - great, got there in the end. The issue was that I failed to re-save my original data as a new layer with the custom CRS -- when I did this, then densified the lines and -re-projected back to WGS 84, I had my curved lines as intended. (I need to learn more about projections!) – NickN Sep 29 '16 at 11:56

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.