55、python画热力图

from folium.plugins import HeatMap, Fullscreen
import folium

def draw_map_heat2(data_heat, output_path='.'):

    lats = [d[0] for d in data_heat]
    lngs = [d[1] for d in data_heat]
    lat_mid = sum(lats) / len(lats)
    lng_mid = sum(lngs) / len(lngs)

    ChinaMap = folium.Map(location=[lat_mid, lng_mid],
                          tiles=None,
                          names='高德地图',
                          attr='高德地图',
                          overlay=False,
                          show=False,
                          zoom_start=10)
    #
    folium.TileLayer('http://webrd02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}',
                     attr='高德地图', name='高德地图').add_to(ChinaMap)

    Fullscreen(
        position='topright',
        title='全屏',
        title_cancel='退出全屏',
        force_separate_button=True
    ).add_to(ChinaMap)

    # 候选点所在地
    site_candicate_point = folium.FeatureGroup(name="各个需求点地址", show=True)
    for d in data_heat:
        gis = str(round(d[0], 3)) + ',' + str(round(d[1], 3))
        site_candicate_point.add_child(folium.Marker(location=d[:2], popup= gis))
    ChinaMap.add_child(site_candicate_point)

    site_candicate_heat_point = folium.FeatureGroup(name="热力图", show=True)
    site_candicate_heat_point.add_child(HeatMap(data_heat))
    ChinaMap.add_child(site_candicate_heat_point)

    folium.LayerControl().add_to(ChinaMap)

    file_path = output_path + "\MapHeat.html"
    ChinaMap.save(file_path)


if __name__ == '__main__':
    data_heat = [[23.149486, 113.454709, 100],
                 [22.797794, 113.140348, 200],
                 [23.438073, 113.648574, 300]]
    draw_map_heat2(data_heat)

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值