Python地理映射的新功能。我正在尝试使用我自己的数据制作叶片模板。没有Choropleth定义图显示正确。添加Choropleth def。导致地图/空间为空。
我检查了许多其他空的地图问题,但无法跟踪该错误。它与geojson列名称有关吗?如何检查此列引用是否正确?
import pandas as pd
import folium
state_geo = r'C:\Users\600039256\Documents\test1\Gemeentegrenzen_2018.json'
opps = r'C:\Users\600039256\Documents\test1\geotest.csv'
state_data = pd.read_csv(opps)
m = folium.Map(location=[52, 5], zoom_start=7)
folium.Choropleth(
geo_data=state_geo,
name='choropleth',
data=state_data,
columns=['code', 'sales'],
key_on='feature.properties.code',
fill_color='YlGn',
fill_opacity=0.7,
line_opacity=0.2,
legend_name='Opportunities'
).add_to(m)
folium.LayerControl().add_to(m)
Out: <folium.map.LayerControl at 0x1e46c5d14e0>
m
这是Json标头:
"type": "FeatureCollection",
"name": "Gemeentegrenzen_2018",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "OBJECTID": 1, "code": "GM0847", "gemeentena": "Someren", "Shape__Are": 0, "Shape__Len": 0, "SHAPE_Leng": 41763.7298094, "InPoly_FID": 1, "SimPgnFlag": 0, "MaxSimpTol": 5, "MinSimpTol": 5, "Shape__A_1": 0.010523453973949, "Shape__L_1": 0.45095115579216 }, "geometry": { "type": "Polygon", "coordinates":
这是csv的样子:
stad,sales,code
Aalsmeer,194322,GM0358
Aalst,25000,GM0297
Aalten,20000,GM0197
Alkmaar,260000,GM0361
任何帮助将不胜感激。
答案 0 :(得分:0)
发现如果Json文件很大,则jupyter画布将不会显示地图。保存为HTML后,它可以在浏览器中很好地显示。