I wrote this code in order to have a map with population in other words i wanted polygan layer but I got an error here is my code:
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=[42.304386,-83.066254],zoom_start=6,tiles="Stamen Terrain")
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_color=color_producer(el),color='grey',fill_opacity=0.7))
fg.add_child(folium.GeoJson(data=open('world.json','r',encoding='utf-8-sig'),style_function=lambda x:{'fillColor':'yellow' }))
map.add_child(fg)
map.save("Map1.html")
this is my error:
Traceback (most recent call last):
File "C:\Users\Vida\Desktop\Webmapping_real\map1.py", line 28, in <module>
fg.add_child(folium.GeoJson(data=open('world.json','r',encoding='utf-8-sig'),style_function=lambda x:{'fillColor':'yellow' }))
File "C:\Users\Vida\AppData\Local\Programs\Python\Python310\lib\site-packages\folium\features.py", line 499, in __init__
self.data = self.process_data(data)
File "C:\Users\Vida\AppData\Local\Programs\Python\Python310\lib\site-packages\folium\features.py", line 544, in process_data
raise ValueError('Cannot render objects with any missing geometries'
ValueError: Cannot render objects with any missing geometries: <_io.TextIOWrapper name='world.json' mode='r' encoding='utf-8-sig'>
PS C:\Users\Vida\Desktop\Webmapping_real>
would you please help me how to fix it?