地图的可视化--Folium

1.安装folium

pip install MarkupSafe-0.23-cp34-none-win_amd64.whl

pip install Jinja2-2.8-py2.py3-none-any.whl

pip install folium

 

2.生成WebMap页面

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import folium
import pandas as pd

# define the polygons
states_geojson = r'../www/html/us-states.json'

# statistic data to connect to our polygons
state_unemployment = r'../www/html/US_Unemployment_Oct2012.csv'

# read the csv statistic data
state_data = pd.read_csv(state_unemployment)
print(state_data)

# Let Folium determine the scale
map = folium.Map(location=[48, -102], zoom_start=3, tiles="Stamen Toner")

# create the leaflet map settings
map.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 file
map.create_map(path='../www/html/ch10-01_folium_map.html')

 

3.修改WebMap页面

image

<!--
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
-->

<script src="http://127.0.0.1/resource/JavaScript/gis/geojquery/jquery-1.11.2.min.js"></script>

 

4.访问WebMap页面

image

posted @ 2016-08-21 09:38  ParamousGIS  阅读(847)  评论(0编辑  收藏  举报