I am comparing the various ways of calculating distance and azimuth between two points with Qgis. I am struggling with the various results and their interpretation.
I need to calculate a loxodromic bearing (rhumb line, i.e. a path beetween two points with constant bearing) : which function should I use ? According to my partial conclusions from the data below, none of them returns loxodromic bearing !
- the bearing and measureLine functions compute orthodromic route and distance (both from the function computeDistanceBearing that uses a Vincenty algorithm which indeed aims to calculate a great circle distance and bearing, according to Wikipedia page)
- the azimuth function computes a calculation with a "flat" formula according to api documentation (note that the computeDistanceFlat function returns the square root of the distance when the coordinates are in degrees and the distance when the coordinates are in meters and Mercator system, cf. numeric example below)
- since my loxodromic calculation seems to be wrong, I don't know if one is close to loxodromic figures
Below are some results of functions and my partial conclusions with the example of New-York (-74,40.73) and Paris (2.34,48.86) - coordinates in long/lat or EPSG 4326.
The results of the various functions are :
tool distance ParistoNY NYtoParis tool.bearing(p1,p2) - 292 54 tool.measureLine(p1,p2) 5850 - - tool.computeDistanceFlat(p1,p2) 76 - - pow(tool.computeDistanceFlat(p1,p2),2) 5893 - - p1.azimuth(p2), p2.azimuth(p1) - 264 84
after conversion of coordinates into Mercator system:
tool distance ParistoNY NYtoParis p1.azimuth(p2), p2.azimuth(p1) - 261 81 tool.computeDistanceFlat(p1,p2) 8593130
Manual calculation from wikipedia formulas for a sphere :
tool distance ParistoNY NYtoParis orthodromic distance and initial route 5830 54 292 loxodromic distance and route 344017235 89 89 manual flat azimuth on epsg4326 - 264 84