#NEWLINE# def distance( p0 , p1 , deg = True , r = r_earth_mean ) : #NEWLINE# #INDENT# '\n    Return the distance between two points on the surface of the Earth.\n\n    Parameters\n    ----------\n    p0 : point-like (or array of point-like) [longitude, latitude] objects\n    p1 : point-like (or array of point-like) [longitude, latitude] objects\n    deg : bool, optional (default True)\n        indicates if p0 and p1 are specified in degrees \n    r : float, optional (default r_earth_mean)\n        radius of the sphere \n\n    Returns\n    -------\n    d : float\n\n    Reference\n    ---------\n    http://www.movable-type.co.uk/scripts/latlong.html - Distance\n\n    Note: Spherical earth model. By default uses radius of 6371.0 km.\n\n    ' #NEWLINE# ( single , ( p0 , p1 ) ) = _to_arrays ( ( p0 , 2 ) , ( p1 , 2 ) ) #NEWLINE# if deg : #NEWLINE# #INDENT# p0 = np . radians ( p0 ) #NEWLINE# p1 = np . radians ( p1 ) #NEWLINE# #UNINDENT# ( lon0 , lat0 ) = ( p0 [ : , 0 ] , p0 [ : , 1 ] ) #NEWLINE# ( lon1 , lat1 ) = ( p1 [ : , 0 ] , p1 [ : , 1 ] ) #NEWLINE# h_dlat = ( sin ( ( ( lat1 - lat0 ) / 2.0 ) ) ** 2 ) #NEWLINE# h_dlon = ( sin ( ( ( lon1 - lon0 ) / 2.0 ) ) ** 2 ) #NEWLINE# h_angle = ( p0 + ( ( cos ( lat0 ) * cos ( lat1 ) ) * h_dlon ) ) #NEWLINE# angle = ( 2.0 * arcsin ( sqrt ( h_angle ) ) ) #NEWLINE# d = ( r * angle ) #NEWLINE# if single : #NEWLINE# #INDENT# d = d [ 0 ] #NEWLINE# #UNINDENT# return d