I am trying to create a web map which shows the locations of volcanoes. I am using the Folium library in Python, and designing it with HTML. I am also using data from a Pandas DataFrame. However, when I run my code, I get the following error:
Traceback (most recent call last): File "webmap.py", line 20, in <module> iframe = folium.IFrame(html=html % (name, name, str(elev)), width=200, height=100) TypeError: not all arguments converted during string formatting
This is my code:
import folium
import pandas
data = pandas.read_csv("Volcanoes.txt")
latitudes = list(data["LAT"])
longitudes = list(data["LON"])
elevations = list(data["ELEV"])
names = list(data["NAME"])
html = """
Volcano name:<br>
<a href="https://www.google.com/search?q=%%22%%s%%22" target="_blank">%s</a><br>
Height: %s m
"""
map = folium.Map(location=[38.58, -99.09], zoom_start=6, tiles="Stamen Terrain")
fg = folium.FeatureGroup(name="My Map")
for lat, lon, elev, name in zip(latitudes, longitudes, elevations, names):
iframe = folium.IFrame(html=html %(name, name, str(elev)), width=200, height=100)
fg.add_child(folium.Marker(location=[lat, lon], popup=folium.Popup(iframe), icon=folium.Icon(color="green")))
map.add_child(fg)
map.save("Map1Advacned.html")
The Pandas DataFrame contains information about each volcano, including its location (latitude and longitude), elevation, and name, which I parsed into a Python array in the first bit of my code.
Does anyone know why this error occurs? Any help would be much appreciated. Thanks in advance!