我试图在folium中渲染15,000个点。当我有少于1000个点时,我得到一个渲染为附加图像的地图(示例地图)。当我包含超过1000个代码时,我的代码返回一个无效的地图或点。以下是我的代码:
z230['marker_color'] = pd.cut(z230['ClosePrice'], bins=5,
labels=['blue','green','yellow','orange','red'])
m = folium.Map(location=[39.2904, -76.6122], zoom_start=12)
for index, row in z230.iterrows():
folium.CircleMarker([row['Latitude'], row['Longitude']],
radius=15, color=row['marker_color']).add_to(m)
m
答案 0 :(得分:0)
我能找到的唯一有用的解决方法是包括群集标记。
from folium.plugins import FastMarkerCluster
x = #your centering coordinates here LAT
y = #your centering coordinates here LONG
z = #your zoomlevel here
your_map = folium.Map(location=[x, y], tiles="OpenStreetMap", zoom_start=z)
callback = ('function (row) {'
'var circle = L.circle(new L.LatLng(row[0], row[1]), {color: "red", radius: 10000});'
'return circle};')
your_map.add_child(FastMarkerCluster(your_df[['your_LAT_col', 'your_LONG_col']].values.tolist(), callback=callback))
your_map