我有这段代码,当我给它方向时,它基本上给了我纬度和经度。它被种植使用谷歌的API,但现在我需要使用Tomtom API。我不知道该怎么做。
import openpyxl
from openpyxl import load_workbook
import pandas as pd
ds_address=('C:/Users...
wb = load_workbook(filename = ds_address)
data = wb['Sheet1']
#########################
######### 02 - API GOOGLE
#########################
import googlemaps
YOUR_API_KEY =
gmaps = googlemaps.Client(key=YOUR_API_KEY)
def geo_coding_google(adrss):
geocode_result = gmaps.geocode(adrss)
lat,lng = geocode_result[0]['geometry']['location']['lat'],geocode_result[0]['geometry']['location']['lng']
return(lat,lng)
#########################
######### 03 - Build Data
#########################
out = []
for r in range(2,101):#42207):
try:
id=str(data.cell(row=r, column=1).value).lower().encode('utf-8').strip()
adrss=str(data.cell(row=r, column=2).value).lower().encode('utf-8').strip()
adrss=str(adrss)+",medellin,antioquia,colombia"
print(adrss)
g_c=geo_coding_google(str(adrss))
#### Save Data
out.append({'id':id,'direccion':adrss,'lat':g_c[0],'lon':g_c[1]})
except IndexError:
out.append({'id':"NA",'direccion':"NA",'lat':"NA"[0],'lon':"NA"[1]})
pass
#########################
######### 04 - Export data
#########################
df = pd.DataFrame(out)
file_name="C:/Users
谢谢