Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

python - getting an error while using folium.GeoJson method

I am currently using 0.12.1 version of folium and python 3.8.3. I am getting a Cannot render objects with any missing geometries: <_io.TextIOWrapper name='world.json' mode='r' encoding='cp1251'> error after executing the following code.

import folium
import pandas

data = pandas.read_csv('Volcanoes.txt')
lat = list(data["LAT"])
lon = list(data["LON"])
elev = list(data["ELEV"])

def dynamic_colors(el):
    if el < 2000:
        color = 'green'
    elif el >=2000 and el <3000:
        color = 'orange'
    else:
        color = 'red'
    return color


map = folium.Map(location=[lat[0], lon[0]], zoom_start=5, 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], popup=folium.Popup(str(el) + ' m', parse_html=True), fill_color=dynamic_colors(el),color='grey', fill_opacity=0.7))

data = open('world.json','r')
fg.add_child(folium.GeoJson(data))
map.add_child(fg)
map.save("Map1.html") 

the Lines that cause an error are

data = open('world.json', 'r')
fg.add_child(folium.GeoJson(data))

How can I solve this issue

question from:https://stackoverflow.com/questions/65935996/getting-an-error-while-using-folium-geojson-method

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...