ValueError:无法用任何缺失的几何形状渲染对象
我写了此代码,以便拥有一张带有人口的地图,换句话说,我想要polygan层,但我有一个错误 这是我的代码:
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")
这是我的错误:
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>
您能帮我如何解决吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论