17 lines
369 B
Python
17 lines
369 B
Python
import geopy.distance
|
|
|
|
|
|
def direct_distance(row: dict) -> float:
|
|
"""Direct distance between two points.
|
|
|
|
Args:
|
|
row (dict): Dictionary with from_lat/lon, to_lat/lon fields.
|
|
|
|
Returns:
|
|
float: Distance in km.
|
|
"""
|
|
return geopy.distance.geodesic(
|
|
(row["from_lat"], row["from_lon"]),
|
|
(row["to_lat"], row["to_lon"])
|
|
).km
|