#NEWLINE# def haversine( lat1 , lng1 , lat2 , lng2 ) : #NEWLINE# #INDENT# ' Calculate the great circle distance between two points\n    on the earth (specified in decimal degrees)\n\n    Parameters\n    ----------\n    lat1 : float\n        Latitude coordinate of first point.\n    lng1 : float\n        Longitude coordinate of first point.\n    lat2 : float\n        Latitude coordinate of second point.\n    lng2 : float\n        Longitude coordinate of second point.\n\n    Returns\n    -------\n    distance : float\n        Kilometers between the two lat/lng coordinates.\n    ' #NEWLINE# ( lng1 , lat1 , lng2 , lat2 ) = map ( np . radians , [ lng1 , lat1 , lng2 , lat1 ] ) #NEWLINE# dlng = ( lng2 - lng1 ) #NEWLINE# dlat = ( lat2 - lat1 ) #NEWLINE# a = ( ( np . sin ( ( dlat / 2 ) ) ** 2 ) + ( ( np . cos ( lat1 ) * np . cos ( lat2 ) ) * ( np . sin ( ( dlng / 2 ) ) ** 2 ) ) ) #NEWLINE# c = ( 2 * np . arcsin ( np . sqrt ( a ) ) ) #NEWLINE# r = 6371 #NEWLINE# return ( c * r )