python - 叶地图制作
问题描述
我无法从带有位置数据的数据框中可视化地图
我有一个从四方数据的 json 文件创建的数据框,我正在尝试可视化提取的位置,但我在显示地图时面临挑战。下面是代码和我面临的错误
soweto_map = folium.Map(location=[soweto_latitude, soweto_longitude],
zoom_start=11) # generate the Soweto map
# add Ecco as a red circle mark
folium.features.CircleMarker(
[soweto_latitude, soweto_longitude],
radius=10,
popup=label,
fill=True,
color='red',
fill_color='red',
fill_opacity=0.6
).add_to(soweto_map)
# add popular spots to the map as blue circle markers
for lat, lng, label in zip(sodataframe.lat, sodataframe.lng,
sodataframe.categories):
folium.features.CircleMarker(
[lat, lng],
radius=5,
popup=label,
fill=True,
color='blue',
fill_color='blue',
fill_opacity=0.6
).add_to(soweto_map)
# display map
soweto_map
AttributeError Traceback (most recent call
last)
<ipython-input-148-c40af89cf70e> in <module>
9 color='red',
10 fill_color='red',
---> 11 fill_opacity=0.6
12 ).add_to(soweto_map)
13
~/conda/envs/python/lib/python3.6/site-packages/folium/features.py in
__init__(self, location, radius, popup, **kw)
868 """
869 def __init__(self, location, radius=10, popup=None, **kw):
--> 870 super(CircleMarker, self).__init__(location=location,
popup=popup)
871 self._name = 'CircleMarker'
872 options = _parse_path(**kw)
~/conda/envs/python/lib/python3.6/site-packages/folium/map.py in
__init__(self, location, popup, icon)
651 self.add_child(Popup(popup))
652 elif popup is not None:
--> 653 self.add_child(popup)
654
655 self._template = Template(u"""
~/conda/envs/python/lib/python3.6/site-packages/branca/element.py in
add_child(self, child, name, index)
106 """Add a child."""
107 if name is None:
--> 108 name = child.get_name()
109 if index is None:
110 self._children[name] = child
AttributeError: 'list' object has no attribute 'get_name'
解决方案
推荐阅读
- codesys - 使用 FB_Init 方法保留功能块
- sql - 在公式中组合度量和维度 (Datastudio)
- angular - Angular 材质树中的对象数组
- reactjs - ThreeJS Gltf 已加载,但模型不可见(生产版本)
- sql - SQL。有限查询
- javascript - 获取excel列作为数组NodeJS
- javascript - 如何正确地从表单中获取数据并发送 GET 请求?
- javascript - 默认情况下关闭 javascript 时,chrom 开发工具功能会失败
- python - 用 unittest 测试类初始化方法
- python - 如何通过 gspread 获取前 300 行 Google 表格