folium 画圆不画

folium draw circle not drawing

我正在尝试画一些圆圈来勾勒出澳大利亚布里斯班附近的考拉踪迹。当我尝试在 jupyter 中使用 运行 时,它会绘制地图,如果我用实际值替换 coordinate[["decimalLatitude"],coordinate["decimalLongitude"]],它会显示,否则不会显示。这是我的代码和数据示例图片。

import folium

map_of_koala_sightings = folium.Map(
    location =[-27.470125,153.021072],
    zoom_start=13, tiles='Stamen Terrain'
)


for coordinate in koala_df:
    try:
        folium.Circle(
        radius=300,
        location = coordinate[["decimalLatitude"],coordinate["decimalLongitude"]],
        color='#3388ff',
            fill=True).add_to(map_of_koala_sightings)
    except:
        pass
map_of_koala_sightings

Sample Data

这对我有用(有坐标的子集)。

import folium
import pandas as pd

koala_df = pd.DataFrame(columns = ['decimalLatitude','decimalLongitude'],
                        data = [[-26.770484,152.838467],
                                [-28.103458,153.375882],
                                [-26.4,146.25]])

print(koala_df.head())


map_of_koala_sightings = folium.Map(
    location =[-27.470125,153.021072],
    zoom_start=5, tiles='Stamen Terrain'
)


for idx,coordinate in koala_df.iterrows():
    folium.Circle(radius=300,
                  location = [coordinate['decimalLatitude'],coordinate['decimalLongitude']],
                  color='#3388ff',
                  fill=True).add_to(map_of_koala_sightings)

#map_of_koala_sightings

#For saving to html file
map_of_koala_sightings.save('koalas.html')

输出:

   decimalLatitude  decimalLongitude
0       -26.770484        152.838467
1       -28.103458        153.375882
2       -26.400000        146.250000

和'koalas.html'包含: