๐บ๏ธ Folium Maps
Folium builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js library.
Mastering this concept will significantly boost your Python data science skills!
๐ป Code Example:
import folium from folium.plugins import MarkerCluster # 1. Base map centered over India (Pynfinity HQ) m = folium.Map( location=[20.5937, 78.9629], zoom_start=5, tiles="CartoDB Positron", ) # 2. Tech hubs in India โ Pynfinity user clusters cities = [ {"name": "Bangalore", "lat": 12.9716, "lon": 77.5946, "users": 4500}, {"name": "Hyderabad", "lat": 17.3850, "lon": 78.4867, "users": 3200}, {"name": "Pune", "lat": 18.5204, "lon": 73.8567, "users": 2800}, {"name": "Mumbai", "lat": 19.0760, "lon": 72.8777, "users": 2100}, {"name": "Chennai", "lat": 13.0827, "lon": 80.2707, "users": 1800}, {"name": "Delhi", "lat": 28.6139, "lon": 77.2090, "users": 3100}, {"name": "Kolkata", "lat": 22.5726, "lon": 88.3639, "users": 1500}, ] # 3. MarkerCluster for dense regions cluster = MarkerCluster(name="Pynfinity Users").add_to(m) for city in cities: folium.Marker( location=[city["lat"], city["lon"]], popup=folium.Popup( f"<b>{city['name']}</b><br>Pynfinity Users: {city['users']:,}", max_width=200, ), tooltip=f"{city['name']} โ {city['users']:,} users", icon=folium.Icon(color="blue", icon="graduation-cap", prefix="fa"), ).add_to(cluster) # 4. Circle overlay for top city folium.CircleMarker( location=[12.9716, 77.5946], radius=40, color="#3498db", fill=True, fill_opacity=0.3, popup="Bangalore โ Largest User Base", ).add_to(m) # 5. Layer control folium.LayerControl().add_to(m) m.save("pynfinity_india_map.html") print("Map saved to pynfinity_india_map.html") print(f"Cities mapped: {len(cities)}")
Keep exploring and happy coding! ๐ป