Created
July 23, 2018 12:40
-
-
Save sergiolucero/600ef961ce7aa289be6b2aaae8fa63f7 to your computer and use it in GitHub Desktop.
Folium101
This file contains hidden or 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 folium, pandas as pd | |
| blc = pd.read_json('https://www.bicilascondes.cl/availability_map/getJsonObject') | |
| blc = blc.drop(['address','addressNumber','district','zip'], axis=1) | |
| m = folium.Map(location=[blc.lat.mean(),blc.lon.mean()], zoom_start=14) | |
| bikes = lambda row: 'red' if row['bikes']==0 else 'purple' if row['bikes']<5 else 'green' | |
| for id, station_data in blc.iterrows(): | |
| folium.Marker((station_data['lat'],station_data['lon']), | |
| icon=folium.Icon(color=bikes(station_data), icon='bicycle'), | |
| popup=station_data.to_frame().to_html(header=False,justify='center')).add_to(m) | |
| m.save('bicis.html') |
Author
sergiolucero
commented
Jul 26, 2018

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