Skip to content

Instantly share code, notes, and snippets.

@justinstrawn
Created February 19, 2019 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinstrawn/97792cad1811bca1db2e1419f928c0ac to your computer and use it in GitHub Desktop.
Save justinstrawn/97792cad1811bca1db2e1419f928c0ac to your computer and use it in GitHub Desktop.
import os, sys, time, math, simplekml, googlemaps
gmaps = googlemaps.Client(key='X')
kml=simplekml.Kml()
for row in open(sys.argv[1],'r').read().strip().split("\n"):
geocode_results = gmaps.places(row, location=sys.argv[2], radius=1000)["results"]
for result in geocode_results:
place_result = gmaps.place(result["place_id"])["result"]
visc = ([x["long_name"] for x in place_result["address_components"] if "route" in x["types"]] or (place_result.get('vicinity')) or [""])[0]
p = kml.newpoint(name=result["name"], description=result["name"] + " " + visc+ " \n" + "".join([u"\xA3" for x in range(0, place_result.get("price_level") or 0)]) + " (" + str(place_result.get("rating")) + ") " + str(place_result.get("website")), coords=[result["geometry"]["location"].values()[::-1] ])
kml.save('jenniferslist.kml')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment