位置应由两个数值组成
Location should consist of two numerical values
使用 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.
我是否必须将列表更改为浮动?
我该如何解决?
您需要遍历您的经纬度长列表:
for index,lat in enumerate(place_lat):
folium.Marker([lat,
place_lng[index]]).add_to(map)
我假设 place_lat
和 place_lang
的长度相同。
enumerate
列表将 return 您在列表中建立索引和值。
使用 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.
我是否必须将列表更改为浮动?
我该如何解决?
您需要遍历您的经纬度长列表:
for index,lat in enumerate(place_lat):
folium.Marker([lat,
place_lng[index]]).add_to(map)
我假设 place_lat
和 place_lang
的长度相同。
enumerate
列表将 return 您在列表中建立索引和值。