Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Created July 17, 2019 15:15
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 sergiolucero/a9c65acf404dd2a6e6c4706cdf0268f0 to your computer and use it in GitHub Desktop.
Save sergiolucero/a9c65acf404dd2a6e6c4706cdf0268f0 to your computer and use it in GitHub Desktop.
mapa BLC con flechas
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)
@sergiolucero
Copy link
Author

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment