1.安装folium
pip install MarkupSafe-0.23-cp34-none-win_amd64.whlpip install Jinja2-2.8-py2.py3-none-any.whlpip install folium
2.生成WebMap页面
#!/usr/bin/env python# -*- coding: utf-8 -*-import foliumimport pandas as pd# define the polygonsstates_geojson = r'../www/html/us-states.json'# statistic data to connect to our polygonsstate_unemployment = r'../www/html/US_Unemployment_Oct2012.csv'# read the csv statistic datastate_data = pd.read_csv(state_unemployment)print(state_data)# Let Folium determine the scalemap = folium.Map(location=[48, -102], zoom_start=3, tiles="Stamen Toner")# create the leaflet map settingsmap.geo_json(geo_path=states_geojson, data=state_data, columns=['State', 'Unemployment'], threshold_scale=[5, 6, 7, 8, 9, 10], key_on='feature.id', fill_color='YlGn', fill_opacity=0.7, line_opacity=0.2, legend_name='Unemployment Rate (%)')# output the final map filemap.create_map(path='../www/html/ch10-01_folium_map.html')
3.修改WebMap页面
4.访问WebMap页面