distance#

distance(lon0, lat0, lon1, lat1, units='km')#

Calculate the distance between two points. Return result in kilometers or miles.

Parameters:
lon0float

Longitude coordinate of the first point.

lat0float

Latitude coordinate of the first point.

lon1float

Longitude coordinate of the second point.

lat1float

Latitude coordinate of the second point.

units{‘mi’, ‘km’}, default=’km’

The units in which the result will be obtained. There are shorthands for values: ‘mi’ (miles), ‘km’ (kilometers).

Returns:
float

Distance between the points.

Examples

1from lets_plot.geo_data import *
2cities = geocode_cities(['New York', 'Chicago']).get_centroids().geometry
3distance(cities[0].x, cities[0].y, cities[1].x, cities[1].y, units='mi')
The geodata is provided by © OpenStreetMap contributors and is made available here under the Open Database License (ODbL).
720.6330581122182