Created
September 26, 2018 01:59
-
-
Save sergiolucero/adcffd6530bed0dc70371ad0281453c0 to your computer and use it in GitHub Desktop.
recorridos transantiago 2018
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import folium, requests, time | |
fm=folium.Map([-33.4,-70.65], zoom_start=12) | |
#LINEAS = ['101','206', '345'] | |
recorridos = eval(requests.get('http://www.transantiago.cl/restservice/rest/getservicios/all').text) | |
LINEAS = recorridos #[:10] | |
t0 = time.time() | |
print('plotting %d recorridos' %len(LINEAS)) | |
tdf = pd.DataFrame() | |
for linea in LINEAS: | |
print(linea) | |
rec = pd.read_json(f'http://www.transantiago.cl/restservice/rest/getrecorrido/{linea}') | |
pars = pd.DataFrame(rec.iloc[0]['paradas']) | |
pars['linea'] = linea | |
pars2 = pd.DataFrame(rec.iloc[1]['paradas']) | |
pars2['linea'] = linea | |
tdf = tdf.append(pars.append(pars2)) | |
folium.PolyLine(pars.pos.values).add_to(fm) | |
fm.save('/home/bitnami/my_flask/static/MAPAS/Transantiago.html') | |
tf = time.time() | |
print('PLOTTED %d in %d secs' %(len(LINEAS), tf-t0)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment