Is the Azimuth on the equator equal to the one not on the equator?

穿精又带淫゛_ 提交于 2019-12-10 20:27:18

问题


I am trying to fully understand the concept of Azimuth and I am encountering some inconsistencies (or maybe it is my error).

I show you some examples that do not match, hoping somebody can explain me how this really works.

I show the coordinates in EPSG:900913, in PostGIS and using my own JavaScript function.

MY FUNCTION

/* Difference between the two longitudes */
var dLon = lon2 - lon1;
/* Y value */
var y = Math.sin(dLon) * Math.cos(lat2);
/* X value */
var x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
/* Calculates the azimuth between the two points and converts it to degrees */
var angle = Math.atan2(y, x) / Math.PI * 180;

EXAMPLES

/* Same Y, not on the equator */
Point A: (-81328.998084106, 7474929.8690234)
Point B: (4125765.0381464, 7474929.8690234)
Result in PostGIS: 90 degrees
Result in my JS function: 74.232 degrees

/* Same Y, on the equator */
Point A: (-81328.998084106, 0)
Point B: (4125765.0381464, 0)
Result in PostGIS: 90 degrees
Result in my JS function: 90 degrees

I understand, that on the equator, the Azimuth is 90 (or 270) for a horizontal line. think that if you draw a horizontal line a bit North (or South) of the equator, then the Azimuth is not 90 degrees anymore. But... PostGIS tells me that it is always 90 degrees when we have the same Y.

Additionally, this calculator also show that the Azimuths of horizontal lines are not 90 degrees when Y != 0 (not on the equator).

How is it correct?

Thanks


回答1:


In your example you have used EPSG:900913, which is planar, projected and in meters. This means that the formula used will be the atan2, which will always be 90 when the latitudes are the same, as the formula is:

azimuth = atan2(y1-y2, x1-x2)

And the 2nd part will always be 0, giving an azimuth of 90. So, using planar coordinates, yes, the azimuth will always be the same for pairs of coordinates with identical latitudes and this is why Postgis always gives the same answer when using EPS:900913.

If you switch to the geography datatype, and therefore use geodesic coordinates, this is no longer the case.

For example:

select degrees(   
  st_azimuth(
   st_makepoint(0, 10)::geography, 
   st_makepoint(90, 10)::geography));

Gives 80.1318065 in Postgis and gives 80.139 on the calculator page you linked.

As the x/longitudes get closer together, the closer the values get to 90, for a given latitude. For example,

select degrees(   
  st_azimuth(
   st_makepoint(0, 10)::geography, 
   st_makepoint(1, 10)::geography));

Now gives 89.9131737 in Postgis and and 89.333 in the online calculator (slightly more discrepancy).

All of this is due to the fact that the formula now accounts for curvature, so the angle between the projections of the two vectors with equal latitude will no longer be 90, except on the equator.

Look at the equation in the Wikipedia azimuth article for the spheroid version. That should be easy enough to code up in JavaScript and that ought to give comparable answers to Postgis with the geography type.



来源:https://stackoverflow.com/questions/25529222/is-the-azimuth-on-the-equator-equal-to-the-one-not-on-the-equator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!