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
Answer
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.
No comments:
Post a Comment