I want to able to determine the angle between two geolocations using python. To able to make it happen I considered movable-type website. When made a lookup for point1(42.386391,-71.019037) and point2(42.387728, -71.016153) on this website I got 57 degrees which totally makes sense in google maps as well.
So I have converted the formula which is shared on the website to python.
This is the formula on the website:

And this is my python code:
def bearing1(lat1, long1, lat2, long2):
cal = math.atan2(np.sin(long2-long1)*np.cos(lat2), np.cos(lat1)*np.sin(lat2)-np.sin(lat1)*np.cos(lat2)*np.cos(long2-long1))
bearing = np.degrees(cal)
return (360+bearing) % 360
But when I run this function I got the angle as 357 degrees.
If you think the red point is point1, and the pink point is point2, the 57-degree angle is so much more sense than 357-degree. (the green X is angle that I want to learn).
Also, I gave a try for the same values on this website, it is 59 degrees again which is not bad. Obviously, I'm missing something in my code. So do you think what am I doing wrong? What should be changed?

I'd be carefull about that np.sin(long2-long1) = - np.sin(long1-long2) that might put a minus somewhere in the computation of arctan(x/y) with np.atan2(x,y)
Not sure your problem comes from there though..
Not sure I understand the problem actually ! You want to compute the angle between the tangent to the earth at some point along the direction towards another point by going straight ahead (like under ground) ?