2014-10-30 9 views
4

안녕하세요, 내가 웹 페이지에 통합 내장 할 수 있습니다 다각형 맵을 만들 geopandas, 팬더와 folium의 조합을 사용하려고 해요파이썬 folium GeoJSON지도는

을 표시하지 않습니다.

누구에게 도움을 줄 수 있는지 표시하거나 궁금하지 않습니다.

단계는 내가 찍은 :

1) 의회의 경계에 대한 영국의 OS에서 .SHP를 잡았다.

2) 나는 다음 형식을 취 GeoJSON로 내 보낸 후 = 4326 및 EPSG에 투사 변경 geopandas을 사용했습니다 : 내가하고 싶은 것을 그리고

{ "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에서 유권자의 dataframe :

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

답변

1

@ elksie5000, 시도해보십시오. 매우 간단합니다. Jupyter/Ipython 노트북에서

pip install mplleaflet 

:

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