alex_bn_lee

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

【531】folium 实现地图可视化(热力图)

参考:Python地图可视化-Folium实例(一)

参考:Python地图可视化-Folium实例(二)

参考:Python地图可视化-Folium实例(三)

参考:Python地图可视化-Folium实例(四)

参考:python高德地图可视化_【可视化】python地图可视化_Folium

参考:Folium 0.12.1 documentation »Quickstart

参考:Python地图可视化 folium

瓦片修改:


点线面显示举例

  Polygon 通过 weight 调整边界线的宽度

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import folium
# 用于 MarkerCluster
import folium.plugins
 
# 加载高德地图瓦片
m=folium.Map(location=[40.00727, 116.486635],
               zoom_start=17,
               tiles='http://webst04.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}',
               attr='default')
 
# 单点,直接加入坐标即可
folium.Marker(
    [40.00777, 116.486635],
    popup=folium.Popup('望京科创园',max_width=1000),
    tooltip='click here').add_to(m)
 
# 多边形,需要所有的点,可以填充颜色
folium.Polygon(
    [[40.00777, 116.485635],
     [40.00697, 116.488035],
     [40.00877, 116.487635]],
    color='red',
    fill_color='red',
    fillOpacity=0.5).add_to(m)
 
# 折线,需要所有的点,只有颜色
folium.PolyLine(
    [[40.00677, 116.485635],
     [40.00597, 116.488035],
     [40.00777, 116.487635]],
    color='green').add_to(m)
 
# 圆圈显示
folium.Circle(
    [40.00677, 116.485635],
    50,
    color='purple',
    fill_color='purple',
    fillOpacity='purple').add_to(m)
 
folium.CircleMarker(
    location=[40.00597, 116.488035],
    radius=20,
    popup="Laurelhurst Park",
    color="#3186cc",
    fill=True,
    fill_color="#3186cc",
).add_to(m)
 
# 显示点集
folium.plugins.MarkerCluster(
    locations=[[40.00677, 116.485635],
               [40.00597, 116.488035],
               [40.00777, 116.487635]],).add_to(m)
 
m

显示效果如下:

 

部分语法如下所示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
Init signature:
folium.Marker(
    location=None,
    popup=None,
    tooltip=None,
    icon=None,
    draggable=False,
    **kwargs,
)
Docstring:    
Create a simple stock Leaflet marker on the map, with optional
popup text or Vincent visualization.
 
Parameters
----------
location: tuple or list
    Latitude and Longitude of Marker (Northing, Easting)
popup: string or folium.Popup, default None
    Label for the Marker; either an escaped HTML string to initialize
    folium.Popup or a folium.Popup instance.
tooltip: str or folium.Tooltip, default None
    Display a text when hovering over the object.
icon: Icon plugin
    the Icon plugin to use to render the marker.
draggable: bool, default False
    Set to True to be able to drag the marker around the map.
 
 
Init signature: folium.Polygon(locations, popup=None, tooltip=None, **kwargs)
Docstring:    
Draw polygon overlays on a map.
 
See :func:`folium.vector_layers.path_options` for the `Path` options.
 
Parameters
----------
locations: list of points (latitude, longitude)
    Latitude and Longitude of line (Northing, Easting)
popup: string or folium.Popup, default None
    Input text or visualization for object displayed when clicking.
tooltip: str or folium.Tooltip, default None
    Display a text when hovering over the object.
**kwargs
    Other valid (possibly inherited) options. See:
    https://leafletjs.com/reference-1.6.0.html#polygon
 
 
Init signature: folium.PolyLine(locations, popup=None, tooltip=None, **kwargs)
Docstring:    
Draw polyline overlays on a map.
 
See :func:`folium.vector_layers.path_options` for the `Path` options.
 
Parameters
----------
locations: list of points (latitude, longitude)
    Latitude and Longitude of line (Northing, Easting)
popup: str or folium.Popup, default None
    Input text or visualization for object displayed when clicking.
tooltip: str or folium.Tooltip, default None
    Display a text when hovering over the object.
smooth_factor: float, default 1.0
    How much to simplify the polyline on each zoom level.
    More means better performance and smoother look,
    and less means more accurate representation.
no_clip: Bool, default False
    Disable polyline clipping.
**kwargs
    Other valid (possibly inherited) options. See:
    https://leafletjs.com/reference-1.6.0.html#polyline
 
 
Init signature:
folium.CircleMarker(
    location=None,
    radius=10,
    popup=None,
    tooltip=None,
    **kwargs,
)
Docstring:    
A circle of a fixed size with radius specified in pixels.
 
See :func:`folium.vector_layers.path_options` for the `Path` options.
 
Parameters
----------
location: tuple[float, float]
    Latitude and Longitude pair (Northing, Easting)
popup: string or folium.Popup, default None
    Input text or visualization for object displayed when clicking.
tooltip: str or folium.Tooltip, default None
    Display a text when hovering over the object.
radius: float, default 10
    Radius of the circle marker, in pixels.
**kwargs
    Other valid (possibly inherited) options. See:
    https://leafletjs.com/reference-1.6.0.html#circlemarker
 
 
 
Init signature:
folium.plugins.MarkerCluster(
    locations=None,
    popups=None,
    icons=None,
    name=None,
    overlay=True,
    control=True,
    show=True,
    icon_create_function=None,
    options=None,
    **kwargs,
)
Docstring:    
Provides Beautiful Animated Marker Clustering functionality for maps.
 
Parameters
----------
locations: list of list or array of shape (n, 2).
    Data points of the form [[lat, lng]].
popups: list of length n, default None
    Popup for each marker, either a Popup object or a string or None.
icons: list of length n, default None
    Icon for each marker, either an Icon object or a string or None.
name : string, default None
    The name of the Layer, as it will appear in LayerControls
overlay : bool, default True
    Adds the layer as an optional overlay (True) or the base layer (False).
control : bool, default True
    Whether the Layer will be included in LayerControls.
show: bool, default True
    Whether the layer will be shown on opening (only for overlays).
icon_create_function : string, default None
    Override the default behaviour, making possible to customize
    markers colors and sizes.
options : dict, default None
    A dictionary with options for Leaflet.markercluster. See
    https://github.com/Leaflet/Leaflet.markercluster for options.

热力图显示(超级简单)

参考:https://www.cnblogs.com/feffery/p/9288138.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 分别显示凸包 以及 所有点
 
m=folium.Map(location=[40.001971, 116.47304],
               zoom_start=18,
               tiles='http://webst04.is.autonavi.com/appmaptile?style=7&x={x}&y={y}&z={z}',
               attr='default')
 
# 显示 polygon
folium.Polygon(tmp_hull, color='red', fill_color='red').add_to(m)
 
for i in range(len(pts)):
    folium.CircleMarker(pts[i], 1, color='purple').add_to(m)
 
folium.plugins.HeatMap(pts).add_to(m)
     
m

 

posted on   McDelfino  阅读(2386)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2012-03-12 【022】◀▶ C# 操作 Excel 等
点击右上角即可分享
微信分享提示