Python script to fetch data from the Google Maps Distance Matrix API. The API is provided here and requires a Google API key that can be found here.
There are two ways of using the script, each corresponding to a mode set in the parameters file 'parameters.py'.
-
By creating a complete duration matrix. (mode = 0)
In this case, you should provide the structure of the graph with the 'graph_structure.csv' provided as an example. The output will be the resulting duration matrix, saved at the location set in the parameters. -
By filling a duration matrix. (mode = 1)
In this case, you should provide the path to the uncomplete duration matrix in the parameters file. The output will be the completed duration matrix, saved at the location set in the parameters.
In each cases, other parameters such as the considered period of time and the time step width are set into the parameters file.
The resulting duration matrix has the following structure:
| Starting location | Goal location | t0 | ... | tM |
|---|---|---|---|---|
| start0 | goal0 | duration0,0 | ... | duration0,M |
| ... | ... | ... | ... | ... |
| startN | goalN | durationN,0 | ... | durationN,M |
Whith the following notations:
- (start0, ..., startN) are the starting locations of the edges;
- (goal0, ..., goalN) are the goal locations of the edges;
- (t0, ..., tM) are the time steps of departure time (s);
- (durationi,j) are the computed durations.