python - 位置应由两个数值组成
问题描述
使用 Jupyter 笔记本
制作地图
place_lat是
[37.4601908,
37.4785259,
37.5618288,
37.5672412,
37.4601908,
37.526152,
37.504487,
37.5277524,
37.526152,
37.681997,
37.642134]
place_lng是
[126.4406957,
126.6685039,
126.8019274,
127.0056589,
126.4406957,
127.028504,
127.048957,
127.01948,
127.028504,
126.77004,
126.8312317]
我在这里遇到错误
map = folium.Map(location=[37.4601908, 126.4406957], zoom_start=11)
for n in place_name:
folium.Marker([place_lat,
place_lng]).add_to(map)
map
错误说
ValueError: Location should consist of two numerical values, but [37.4601908, 37.4785259, 37.5618288, 37.5672412, 37.4601908, 37.526152, 37.504487, 37.5277524, 37.526152, 37.681997, 37.642134] of type <class 'list'> is not convertible to float.
我应该将列表更改为浮动吗?
我该如何解决?
解决方案
你需要遍历你的 lat,long 列表:
for index,lat in enumerate(place_lat):
folium.Marker([lat,
place_lng[index]]).add_to(map)
我假设你有相同的长度place_lat
和place_lang
。
enumerate
在列表上将返回列表中的索引和值。
推荐阅读
- typescript - 如何正确输入反应原生 svg 路径以获得 getTotalLength?
- reactjs - 未找到 React Native 处理 404
- c++ - 在 QT 中用完全透明的笔“绘图”
- python - 在数据框python中迭代具有唯一值的槽单元
- multithreading - 共享指针如何导致多线程中的线程安全
- swift - 斯威夫特 5.1 。使用 UITableView 将 firestore 文档分页 x 次
- javascript - 拆分、求和和迭代整数数组,直到每一边相等(Javascript)
- javascript - 从购物车中删除物品 Redux,React
- php - 如何在 Laravel 中设置 %Y-%m 条件以获取日期 < %Y-%n
- html - 在 Bootstrap 中格式化定价卡