Skip to content

Instantly share code, notes, and snippets.

@sergiolucero
Last active September 4, 2021 12:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergiolucero/714cb8cb25a9965d999464b51ccd1ce1 to your computer and use it in GitHub Desktop.
Save sergiolucero/714cb8cb25a9965d999464b51ccd1ce1 to your computer and use it in GitHub Desktop.
building a realistic Train Conductor World Map
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')
@sergiolucero
Copy link
Author

tcw_v1

@sergiolucero
Copy link
Author

created (and sent original carto link to Simon Joslin) 08/26

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