Link to home
Start Free TrialLog in
Avatar of chalie001
chalie001

asked on

error in python script

hi am having error in my script
python mapView.py
Traceback (most recent call last):
  File "mapView.py", line 44, in <module>
    style_function=lambda x: {'fillColor':'yellow'}))
  File "C:\ProgramData\Anaconda3\lib\site-packages\folium\features.py", line 450, in __init__
    self.data = self.process_data(data)
  File "C:\ProgramData\Anaconda3\lib\site-packages\folium\features.py", line 494, in process_data
    ': {!r}'.format(data))
ValueError: Cannot render objects with any missing geometries: <_io.TextIOWrapper name='world.json' mode='r' encoding='utf-8-sig'>
this my script
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(elevetion):
    if elevetion < 1000:
        return  'green'
    elif 1000 <= elevetion < 3000:
        return 'orange'
    else:
        return 'red'	


#map = folium.Map(location=[lat, lon], zoom_start=6, tiles="Stamen Terrain")
#map = folium.Map(location=[lat[0], lon[0]], zoom_start=5, tiles="Stamen Terrain")

map = folium.Map(location=[38.58,-99.09], zoom_start=5, tiles="Mapbox Bright")

#map = folium.Map(location=[0, 0], zoom_start=6)



fg = folium.FeatureGroup(name="My Map")

#for lt,ln,el in zip(lat,lon,elev):
 #    fg.add_child(folium.Marker(location=[lt, ln],popup=str(el)+" m",icon=folium.Icon(color=color_producer(el)))
	 
for lt,ln,el in zip(lat,lon,elev):
     fg.add_child(folium.CircleMarker(location=[lt, ln],popup=str(el)+" m",
	 fill_color=color_producer(el),color = 'grey',fill_opacity=0.7))
	 #icon=folium.Icon(color=color_producer(el))))	 

	 
	 
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("map092.html")	

Open in new window

Volcanoes.txt
world.json
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial