Last active
September 4, 2021 12:27
-
-
Save sergiolucero/714cb8cb25a9965d999464b51ccd1ce1 to your computer and use it in GitHub Desktop.
building a realistic Train Conductor World Map
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 folium, random, pandas as pd | |
from urllib.request import urlopen | |
colors=['red','blue','green','orange','yellow'] | |
URL = 'http://sergiolucero.carto.com/api/v2/sql?format=csv&q=SELECT%20*,ST_AsText(the_geom)%20AS%20g2%20FROM%20' | |
ZOOM_LEVEL = 5;TILES='cartodbdark_matter' | |
CARTO_DATABASE = 'tcw' | |
response = urlopen(URL+CARTO_DATABASE) | |
data = pd.read_csv(response) | |
centroid = (data.lat.median(),data.lng.median()) | |
basemap = folium.Map(location=centroid,tiles=TILES,zoom_start=ZOOM_LEVEL) | |
for ix, dda in data.iterrows(): | |
icon = folium.Icon(color=colors[random.randint(0,len(colors)-1)]) | |
folium.Marker(location=[dda.lat,dda.lng], | |
icon=icon).add_to(basemap) | |
basemap.save('tcw.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
created (and sent original carto link to Simon Joslin) 08/26