How to Calculate Distance Matrix using Google Maps in Python | Python | Google Maps

How to Calculate Distance Matrix using Google Maps in Python | Python | Google Maps

Siddhartha Paul

1 год назад

11,127 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Sharjeel Akhtar
Sharjeel Akhtar - 19.10.2023 09:32

Thanks for the video. When you are calculating distance matrix, does google charge you based on number of API calls or on the basis of number of origins X number of destinations?

Ответить
Prince Ireye
Prince Ireye - 21.08.2023 14:51

Thanks. This tutorial has been super helpful. I keep getting the following index error when trying to iterate through the rows to get the distance and travel time:
<ipython-input-14-82106501bbfa> in <cell line: 1>()
3 direction_result = gmaps_client.directions(row['from_lat_long'], row['to_lat_long'],
4 mode = "driving", avoid = "ferries", departure_time = start_time)
----> 5 df.loc[index, 'distance'] = direction_result[0]['legs'][0]['distance']['value']
6 df.loc[index, 'travel_time'] = direction_result[0]['legs'][0]['duration']['value']
7 df.loc[index, 'distance_text'] = direction_result[0]['legs'][0]['distance']['text']

IndexError: list index out of range

Do you have any recommendations?

Ответить
Nancy
Nancy - 01.07.2023 06:57

Hi, thank you for your videl. If I may ask, there are some option parameters in distance matrix api, such as we can set up trafifc_model as 'best_guess', 'pessimistic', 'optimistic'. can we set up these parameters?

Ответить
Duc Nguyen Hong
Duc Nguyen Hong - 09.02.2023 12:34

Hi, thanks your video, it is usefull to me could you share your source code?

Ответить
fikri fikri
fikri fikri - 09.01.2023 16:05

hi. thank you for your explanation about the distance matrix calculation. that's so helpful for me to understand. if i may ask, how can u get thos latlong data? can we use the geocode in gmaps api? please kindly enlighten me. thank you!

Ответить