Recently, I have been experimenting with the Google Maps API for python and R. I have gotten it in Python so it will return a list of directions to get from point A to point B.
from googlemaps import GoogleMaps
mapService = GoogleMaps()
directions = mapService.directions('Houston', 'Atlanta')
for step in directions['Directions']['Routes'][0]['Steps']:
print step['descriptionHtml']
This returns a list of turns etc, but I want to extrapolate the geocoordinates at each step in the directions. For example, running the previous code returns:
Head <b>northeast</b> on <b>Bagby St</b> toward <b>Walker St</b>
Turn left onto <b>Walker St</b>
Merge onto <b>I-45 N</b> via the ramp on the left to <b>Dallas</b>
Take exit <b>48A</b> for <b>Interstate 10 E</b> toward <b>Beaumont</b>
Merge onto <b>I-10 E</b>
Keep left to stay on <b>I-10 E</b>
Keep left to stay on <b>I-10 E</b><div class="google_note">Entering Louisiana</div>
Keep left to continue on <b>I-12 E</b>, follow signs for <b>Hammond</b>
Take exit <b>85B-85C</b> on the left toward <b>I-59 N/<wbr/>I-10 E/<wbr/>Bay St Louis/<wbr/>Hattiesburg</b>
Take exit <b>85C</b> on the left to merge onto <b>I-10 E</b> toward <b>Bay St Louis</b><div class="google_note">Passing through Mississippi</div><div class="google_note">Entering Alabama</div>
Take exit <b>20</b> on the left to merge onto <b>I-65 N</b> toward <b>Montgomery</b>
Take exit <b>171</b> to merge onto <b>I-85 N</b> toward <b>Atlanta</b><div class="google_note">Entering Georgia</div>
Take exit <b>246</b> for <b>Fulton St/<wbr/>Central Ave</b> toward <b>Downtown</b>
Keep right at the fork, follow signs for <b>Fulton Street</b>
Turn right onto <b>Fulton St SW</b>
Turn left onto <b>Capitol Ave SE</b>
How can I, for example, get the current geocode location after step 1, step 2 etc. I am planning to use this information in R after, so if it is easier to do this in R that would be even better.