2014-10-30 45 views
4

下午好,的Python大青叶GeoJSON的地图不显示

我试图使用geopandas,熊猫和大青叶的组合来创建一个多边形地图,我可以嵌入纳入一个网页。

出于某种原因,它不显示并且怀疑是否有人可以提供帮助。

的步骤我已经采取了:

1)抓起来自英国的OS议会边界的.SHP。

2)我然后用于geopandas改变投影EPSG = 4326,然后导出为以GeoJSON这需要以下格式:

{ "type": "Feature", "properties": { "PCON13CD": "E14000532", "PCON13CDO": "A03", "PCON13NM": "Altrincham and Sale West" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -2.313999519326579, 53.357408280545918 ], [ -2.313941776174758, 53.358341455420039 ], [ -2.31519699483377, 53.359035664493433 ], [ -2.317953152796459, 53.359102954309151 ], [ -2.319855973429864, 53.358581917200119 ],... ] ] ] } },... 

然后我想要做的是什么网,带本选区在下面的格式,DTY一个数据帧:

constituency  count 
0 Burton   667 
1 Cannock Chase 595 
2 Cheltenham  22 
3 Cheshire East 2 
4 Congleton  1 
5 Derbyshire Dales 1 
6 East Staffordshire 4 

import folium 
mapf = folium.Map(width=700, height=370, tiles = "Stamen Toner", zoom_start=8, location=  ["53.0219392","-2.1597434"]) 


mapf.geo_json(geo_path="geo_json_shape2.json", 
       data_out="data.json", 
       data=dty, 
       columns=["constituency","count"], 
       key_on="feature.properties.PCON13NM.geometry.type.Polygon", 
       fill_color='PuRd', 
       fill_opacity=0.7, 
       line_opacity=0.2, 
       reset="True") 

从mapf输出看起来像:

mapf.json_data

{'../../Crime_data/staffs_data92.json': [{'Burton': 667, 
    'Cannock Chase': 595, 
    'Cheltenham': 22, 
    'Cheshire East': 2, 
    'Congleton': 1, 
    'Derbyshire Dales': 1, 
    'East Staffordshire': 4, 
    'Lichfield': 438, 
    'Newcastle-under-Lyme': 543, 
    'North Warwickshire': 1, 
    'Shropshire': 17, 
    'South Staffordshire': 358, 
    'Stafford': 623, 
    'Staffordshire Moorlands': 359, 
    'Stoke-on-Trent Central': 1053, 
    'Stoke-on-Trent North': 921, 
    'Stoke-on-Trent South': 766, 
    'Stone': 270, 
    'Tamworth': 600, 
    'Walsall': 1}]} 

尽管mapf.create_map()函数成功创建了一个贴图,但多边形不会渲染。

任何人都可以提出任何调试步骤?

我从来没有清楚如何添加完整的数据文件,如果任何人需要他们,所以请让我知道。

非常感谢您提前预约。

+0

张贴在某个地方,用于调试目的的现场演示的任何机会呢? – snkashis 2015-05-16 17:27:28

回答

1

@ elksie5000,尝试mplleaflet它非常简单。

pip install mplleaflet 

在Jupyter/IPython的笔记本:

import mplleaflet 
ax = geopandas_df.plot(column='variable_to_plot', scheme='QUANTILES', k=9, colormap='YlOrRd') 
mplleaflet.show(fig=ax.figure)