SHARE
TWEET

Untitled

a guest Dec 15th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def sphere_dist(pickup_lat, pickup_lon, dropoff_lat, dropoff_lon):
  2.   """
  3.   Return distance along great radius between pickup and dropoff coordinates.
  4.   """
  5.   #Define earth radius (km)
  6.   R_earth = 6371
  7.   #Convert degrees to radians
  8.   pickup_lat, pickup_lon, dropoff_lat, dropoff_lon = map(np.radians, [pickup_lat, pickup_lon, dropoff_lat, dropoff_lon])
  9.  
  10.   #Compute distances along lat, lon dimensions
  11.   dlat = dropoff_lat - pickup_lat
  12.   dlon = dropoff_lon - pickup_lon
  13.  
  14.   #Compute haversine distance
  15.   a = np.sin(dlat/2.0)**2 + np.cos(pickup_lat) * np.cos(dropoff_lat) * np.sin(dlon/2.0)**2
  16.  
  17.   return 2 * R_earth * np.arcsin(np.sqrt(a))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top