如何用folium聚类圆形标记?

如何解决如何用folium聚类圆形标记?

一些标记放置得很近,墨尔本有 4 个标记,放大时可见,我想在缩小时有一个带有计数的聚集标记。那可能吗? 请参阅下面的代码、数据框和我的输出

我的输出

my output

墨尔本特写:

Melbourne close up

import pandas as pd

world_geo = r'world_countries.json' # geojson file

world_map = folium.Map(
    location = [0,0],zoom_start = 3,width = 1500,height = 1100,tiles = 'cartodb positron',prefer_canvas = True,max_bounds = True
)
world_map.choropleth( 
    name = 'choropleth WB100',geo_data = world_geo,data = dfcv,columns = ['Country','Total'],key_on = 'feature.properties.name',nan_fill_color = 'white',nan_fill_opacity = 0.1,fill_color = 'Greens',fill_opacity = 0.7,line_opacity = 0.2,legend_name = 'Worlds Best 100 Bars'
)

world_map

mapa = folium.map.FeatureGroup()

for lat,lng,bar,city,pos in zip(
    df.Latitude,df.Longitude,df.Bar,df.City,df.wb_pos):
    
    label= '{},{},Number {}'.format(bar,pos) 
    
    mapa.add_child(
        folium.CircleMarker(
            [lat,lng],label = label,popup = label,radius = 5,color = 'yellow',fill = True,fill_color = 'blue',fill_opacity = 0.6
        ).add_to(mapa)
    )

# Build a CircleMarker for each row based on the lat long of the record
df.apply(lambda row: folium.CircleMarker(
    location=[row["Latitude"],row["Longitude"]],radius=10,).add_to(world_map),axis=1)

world_map.add_child(mapa)

请参阅下面的 df 数据框:

{'Bar': {0: 'Connaught Bar',1: 'dante',2: 'The Clumsies',3: 'Atlas',4: 'Tayēr + Elementary'},'City': {0: 'London',1: 'New York',2: 'athens',3: 'Singapore',4: 'London'},'Country': {0: 'UK',1: 'USA',2: 'Greece',4: 'UK'},'Delivery': {0: 0,1: 1,2: 1,3: 1,4: 1},'Latitude': {0: 51.507358,1: 40.7129,2: 37.9838,3: 1.352,4: 23.7276},'Longitude': {0: 0.1278,1: -74.006,2: 23.7275,3: 103.8198,4: 0.1278},'Region': {0: 'Europe',1: 'north America',2: 'Europe',3: 'Asia',4: 'Europe'},'Shop': {0: 1,2: 0,'Takeway': {0: 0,3: 0,'Virtual Events': {0: 0,1: 0,4: 0},'first_submission': {0: 0,'wb_pos': {0: 1,1: 2,2: 3,3: 4,4: 5}}

可能不相关,但为了避免混淆,请参阅下面的 dfcv 数据框:

{'Country': {0: 'United Kingdom',1: 'United States of America',2: 'Singapore',3: 'Australia',4: 'China'},'Total': {0: 13,1: 12,2: 7,3: 7,4: 6}}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?