Search code examples
pythonjupyter-notebookfolium

Location should consist of two numerical values


Using Jupyter Notebook

making map

place_lat is

[37.4601908,
 37.4785259,
 37.5618288,
 37.5672412,
 37.4601908,
 37.526152,
 37.504487,
 37.5277524,
 37.526152,
 37.681997,
 37.642134]

place_lng is

[126.4406957,
 126.6685039,
 126.8019274,
 127.0056589,
 126.4406957,
 127.028504,
 127.048957,
 127.01948,
 127.028504,
 126.77004,
 126.8312317]

and I got error at here

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

error says

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.

should I have to change list to float?

how can I fix it?


Solution

  • you need to iterate over your lat,long list:

    for index,lat in enumerate(place_lat):
    folium.Marker([lat,
                   place_lng[index]]).add_to(map)
    

    I am assuming you have same length of place_lat and place_lang.

    enumerate over a list will return you index and value in the list.