[GIS] How does QGIS calculate distances when the data is not projected (WGS84)

coordinate systemqgiswgs84

I am playing a bit around with Qgis 2.14.6 to understand how it deals with distance measurement.

I took a line-shapefile that I saved in 3 different coordinate systems (4326, 32642 and a national one that doesn't exist in Qgis yet).

Using 32642 and the national one, the length is quite similar (6442m vs. 6428m)

But using 4326 (unprojected WGS84), I get 8057m

In all cases, I just used the Field Calculator and introduced $length.

I was already positively surprised that the result using 4326 was in meters and not in degrees.

To calculate the distance on the dataset in 4326, I assume that Qgis does some kind of re-projection in the background. Does anyone know which one?

Shapefiles here if anyone wants to play around: http://bit.ly/2cwe4w9

EDIT – adding more info after more tests

As you can see, now both my shapefile and the project are in EPSG:4326, so unprojected:

enter image description here

Here the rough measurement of my shapefile, with the Qgis measure tool:
enter image description here

When I use the field calculator, the preview gives me a value in degrees, while the result seems to be in meters:

enter image description here

enter image description here

This would mean that the function $length, like the measurement tool, always gives a result in meters, but using a very coarse approximation of the degrees => meters transformation:

enter image description here

Is this a bug? or should it really behave like this? I find it at best counter-intuitive (but maybe it's just me) and, at worse, completely misleading (it makes very little sense to use, everywhere on earth, the length of 1 degree at the Equator). Any input or opinion here? Should I open a bug report (at least for the inconsistency between the preview and the actual result)?

Best Answer

Have a look under the "Project Properties" dialog. QGIS will use the project's settings for ellipsoid when calculating distances in a degree based coordinate system.

If you're not using OTF reprojection or have no ellipsoid set, then measurements will usually be cartesian (ie in degrees or degrees squared).

The one exception to this is if you change the units in the measure dialog to something like metres while OTF reprojection is off and you're using a degree based CRS. In this case QGIS will use the very rough approximation of 1 degree = 111300 metres. All this is described in the notes at the bottom of the measure dialog.

I'd suggest enabling OTF reprojection and selecting a suitable ellipsoid in the project properties dialog to get accurate distance measurements.