I was trying the following line of codes in python (that I learnt from a tutorial),
import folium
import pandas
data=pandas.read_csv("Volcanoes.txt")
lat = list(data["LAT"])
lon = list(data["LON"])
elev = list(data["ELEV"])
def color_producer(elevation):
if elevation < 1000:
return 'green'
elif 1000 <= elevation < 3000:
return 'orange'
else:
return 'red'
map = folium.Map(location=[38.58, -99.09], zoom_start=6, tiles="Mapbox Bright")
fg = folium.FeatureGroup(name="My Map")
for lt, ln, el in zip(lat, lon, elev):
fg.add_child(folium.CircleMarker(location=[lt, ln], radius = 6, popup=str(el)+" m",
fill=True, fill_color=color_producer(el), color = 'grey', fill_opacity=0.7))
fg.add_child(folium.GeoJson(data=(open('world.json', 'r', encoding='utf-8-sig'))))
map.add_child(fg)
map.save("Map1.html")
I receive an error saying
Traceback (most recent call last): File "map1.py", line 23, in <module> fg.add_child(folium.GeoJson(data=(open('world.json', 'r', encoding=' utf-8-sig')))) File "C:\Users\TOSHIBA\AppData\Local\Programs\Python\Python36-32\lib\s ite-packages\folium\features.py", line 495, in __init__ raise ValueError('Unhandled object {!r}.'.format(data)) ValueError: Unhandled object <_io.TextIOWrapper name='world.json' mode=' r' encoding='utf-8-sig'>.
I typed exactly the code what I learnt from tutorial course, but seems the code not working for me. Please help me identify the problem ! I was trying it on Atom 1.21.0 or is there any changes made in folium ?