【发布时间】:2020-06-13 19:03:45
【问题描述】:
enter image description here我正在使用 python folium 开发显示印度机场的地图,我使用 pandas 从 csv 读取数据并将坐标分配给 folium.Maker 位置,我收到此错误
Traceback (most recent call last):
File "/Users/user/Downloads/mapping/folium/folium/utilities.py", line 59, in validate_location
float(coord)
ValueError: could not convert string to float: '#geo +lat'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "map1.py", line 15, in <module>
fg.add_child(folium.Marker(location=[lt, ln], popup="Hi there", icon=folium.Icon(color="green")))
File "/Users/user/Downloads/mapping/folium/folium/map.py", line 277, in __init__
self.location = validate_location(location)
File "/Users/user/Downloads/mapping/folium/folium/utilities.py", line 63, in validate_location
.format(coord, type(coord)))
ValueError: Location should consist of two numerical values, but '#geo +lat' of type <class 'str'> is not convertible to float.
import folium
import pandas
data = pandas.read_csv("aiports.csv")
lat = list(data["latitude_deg"])
lon = list(data["longitude_deg"])
map = folium.Map(location = [20.5937 ,78.9629], zoom_start=4, tiles = "Stamen Terrain")
fg = folium.FeatureGroup(name="My Map")
for lt, ln in zip(lat, lon):
fg.add_child(folium.Marker(location=[lt, ln], popup="Hi there", icon=folium.Icon(color="green")))
map.add_child(fg)
map.save("Map1.html")
【问题讨论】:
-
请提供 map1.py 中的代码和 csv 文件的摘录。
-
请提供您的代码
-
我已经上传了代码
标签: python python-3.x pandas maps folium