Calculate the great circle distance between two points on earth in Kilometers
    on the earth (specified in decimal degrees)

    .. seealso:: :func:`distance_points`

    :param float lon1: longitude of first place (decimal degrees)
    :param float lat1: latitude of first place (decimal degrees)
    :param float lon2: longitude of second place (decimal degrees)
    :param float lat2: latitude of second place (decimal degrees)
    :param earth_radius: earth_radius (use 6367 for KM 6367000 for meters 3956 for miles
        - http://stackoverflow.com/questions/5283900/what-earth-radius-should-i-use-to-calculate-distances-near-the-poles

    :Example:
        >>> London_long=-0.126 ; London_lat=51.50; Paris_long = 2.350; Paris_lat = 48.856
        >>> haversine(London_long, London_lat, Paris_long, Paris_lat)
        342.55375272454864

    :returns: float distance in Kilometers

def haversine(lon1, lat1, lon2, lat2, earth_radius=6357000):
    """Calculate the great circle distance between two points on earth in Kilometers
    on the earth (specified in decimal degrees)

    .. seealso:: :func:`distance_points`

    :param float lon1: longitude of first place (decimal degrees)
    :param float lat1: latitude of first place (decimal degrees)
    :param float lon2: longitude of second place (decimal degrees)
    :param float lat2: latitude of second place (decimal degrees)
    :param earth_radius: earth_radius (use 6367 for KM 6367000 for meters 3956 for miles
        - http://stackoverflow.com/questions/5283900/what-earth-radius-should-i-use-to-calculate-distances-near-the-poles

    :Example:
        >>> London_long=-0.126 ; London_lat=51.50; Paris_long = 2.350; Paris_lat = 48.856
        >>> haversine(London_long, London_lat, Paris_long, Paris_lat)
        342.55375272454864

    :returns: float distance in Kilometers

    """
    # convert decimal degrees to radiant
    lon1, lat1, lon2, lat2 = list(map(math.radians, [lon1, lat1, lon2, lat2]))
    # haversine formula
    dlon = lon2 - lon1
    dlat = lat2 - lat1
    a = math.sin(dlat/2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon/2)**2
    c = 2 * math.asin(math.sqrt(a))
    distance = earth_radius * c  # 6371 # Radius of earth in kilometers. Use 3956 for miles
    return distance