4

I am trying to use qgis API to calculate the angle between two points by using function azimuth of class QgsPoint ( http://qgis.osgeo.org/api/classQgsPoint.html ), and my CRS is EPSG:4326 - WGS 84 , but I believe I am getting the angles wrong, as if QGIS were ignoring that the coordinates are Latitude and Longitude. Could it be possibly true? If yes, how can I properly calculate the angle and why would one want to make such a confusing function?
Thanks in advance

3

You can look at the source code of azimuth() to see exactly what QGIS does:

double QgsPoint::azimuth( const QgsPoint& other )
{
   double dx = other.x() - m_x;
   double dy = other.y() - m_y;
   return ( atan2( dx, dy ) * 180.0 / M_PI );
}

The calculations are performed without any CRS check. You as user/developer have to reproject the data properly.

  • Thanks, I had checked and I was in denial of reality that one would make such a trap. – user2759511 Jan 23 '14 at 20:07
  • 1
    +1. In this context "properly" means with a projection that is (1) conformal at the angle's vertex and (2) in which rays on the map emanating from the angle's vertex correspond to geodesics on the earth. For widely separated points, those requirements more or less limit the choices to customized aspects of standard azimuthal projections such as the Stereographic, Gnomonic, and Equidistant (centered at the angle's vertex). For nearby points (within a thousand kilometers or so, depending on accuracy requirements) most conformal projections will be ok, whether azimuthal or not. – whuber Jan 23 '14 at 20:07

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.