ValueError:无法用任何缺失的几何形状渲染对象

发布于 2025-02-09 08:16:07 字数 1733 浏览 2 评论 0原文

我写了此代码,以便拥有一张带有人口的地图,换句话说,我想要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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文