Distance Matrix

Hi all,

I would like to iterate a CSV file with two columns with the city of origin and city of destination, to calculate the distance in spatial and temporal terms, using python

I know that there is a GoogleMaps python module that allow us to do this with the following sentence

for row in csv_file:
Name1=row[0]
Name2=row[1]
result = gmaps.distance_matrix(Name1, Name2, mode=“driving”)

is there any function that allow us to get the distances using GraphHooper? I’d rather use FOSS than GMaps. Surely, we will have to pay a subscription because we need many directions.

Or better: a graphical interface where you can upload a CSV file and you get the result automatically, just like cartociudad (in Spanish) CartoCiudad

This is for research purposes.

Many thanks

Yes, you can do this with GraphHopper. First you need to find the coordinates of your locations. This is called geocoding and is described here: Documentation - GraphHopper Directions API

Once you got the GPS coordinates of all your locations you can calculate the distances using the Matrix API: Documentation - GraphHopper Directions API

Also make sure to read the documentation for general usage of the GraphHopper APIs: Documentation - GraphHopper Directions API