from math import sin, cos, sqrt, atan2, radians


def lat_lon_2_distance(lat1, lon1, lat2, lon2):
    """
    return distance (in km) between two locations (lat1, lon1) and (lat2, lon2)
    
    parameter
    ---------
        lat1, lat2: latitude in degrees
        lon1, lon2: longitude in degrees
        
    return
    ------
        distance in km
    """

    # approximate radius of earth in km
    R = 6373.0

    lat1 = radians(lat1)
    lon1 = radians(lon1)
    lat2 = radians(lat2)
    lon2 = radians(lon2)

    dlon = lon2 - lon1
    dlat = lat2 - lat1

    a = sin(dlat / 2)**2 + cos(lat1) * cos(lat2) * sin(dlon / 2)**2
    c = 2 * atan2(sqrt(a), sqrt(1 - a))

    distance = R * c
    
    return distance