Skip to content Skip to sidebar Skip to footer

How To Compare Great Circle Distance With Euclidean Distance Of Two Sphere Points Using Python?

I am trying to check the error that is introduced when you compute the distance of two points on earth with the euclidean distance instead of using the great circle distance (gcd).

Solution 1:

Python includes two functions in the math package; radians converts degrees to radians, and degrees converts radians to degrees.

The method sin() returns the sine of x, in radians.

import math
def spherical_to_cartesian(r,la,lo):
   rlo = math.radians(lo)
   rla = math.radians(90-la)
   x=r*np.sin(rla)*np.cos(rlo)
   y=r*np.sin(rla)*np.sin(rlo)
   z=r*np.cos(rla)
   return (x,y,z)

Post a Comment for "How To Compare Great Circle Distance With Euclidean Distance Of Two Sphere Points Using Python?"