Created
July 17, 2019 15:15
-
-
Save sergiolucero/a9c65acf404dd2a6e6c4706cdf0268f0 to your computer and use it in GitHub Desktop.
mapa BLC con flechas
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
from math import atan | |
import folium, pandas as pd | |
viajes = pd.read_html('http://quant.cl/blc_read')[0] | |
fm = folium.Map(location=[-33.41,-70.59], zoom_start=14, | |
width=1000, height=400, tiles='stamenwatercolor') | |
for idx, row in viajes.iterrows(): | |
fromloc, toloc = eval(row['fromloc']), eval(row['toloc']) # viene como "string" | |
angulo = 90*atan((fromloc[0]-toloc[0])/(fromloc[1]-toloc[1])) # trigonometría: tan=opp/adj | |
speed = row['speed'] | |
color = 'green' if speed>12 else 'yellow' if speed>8 else 'red' | |
folium.PolyLine([fromloc,toloc], color=color).add_to(fm) | |
folium.RegularPolygonMarker(location=toloc, fill_color='blue', | |
number_of_sides=3, radius=10, | |
rotation=angulo).add_to(fm) |
Author
sergiolucero
commented
Jul 17, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment