lets_plot.geo_data.distance

lets_plot.geo_data.distance(lon0, lat0, lon1, lat1, units='km')

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

Parameters
  • lon0 (float) – Longitude coordinate of the first point.

  • lat0 (float) – Latitude coordinate of the first point.

  • lon1 (float) – Longitude coordinate of the second point.

  • lat1 (float) – 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

Distance between the points.

Return type

float

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