Python实现地图可视化 folium
1.安装folium模块
pip install folium
2.安装jupyter
pip install jupyter
便于查看地图
3.查看世界地图
import folium
m = folium.Map() # 显示地图
m
4.查看中国地图
import folium
m = folium.Map(location=[30,100],zoom_start=3)
m
- location 经纬度,list 或者 tuple 格式,顺序为 latitude(纬度), longitude(经度)
- zoom_start 缩放值,默认为 10,值越大比例尺越小,地图放大级别越大
- tiles 显示样式,默认*‘OpenStreetMap’*,也就是开启街道显示
- crs 地理坐标参考系统,默认为"EPSG3857"
5.武汉市地图
m = folium.Map(location=[30.6,114.4],zoom_start=8) # 武汉市地图
修改样式
m = folium.Map(location=[30.6,114.4],zoom_start=8,tiles='Stamen Toner')
m = folium.Map(location=[30.6,114.4],zoom_start=8,tiles='Stamen Terrain')
6.添加标记
import folium
wuhan_map = folium.Map(location=[30.6,114.4],zoom_start=8)
# 添加标记
folium.Marker(
location=[30.6,114.3], # 位置
popup='Wu Han City Marker', # 鼠标点击 弹出的说明
icon=folium.Icon(icon='cloud') # 图标样式
).add_to(wuhan_map)
folium.Marker(
location=[30.6,114.33],
popup='Timberline Lodge',
icon=folium.Icon(color='green')
).add_to(wuhan_map)
folium.Marker(
location=[30.6,114.35],
popup='Some Other Location',
icon=folium.Icon(color='red', icon='info-sign')
).add_to(wuhan_map)
folium.Circle( # 添加圆
radius=200,
location=(30.6,114.32),
popup='The Waterfront',
color='crimson',
fill=False,
).add_to(wuhan_map)
folium.CircleMarker( #添加蓝色圆环
location=(30.6,114.37),
radius=50,
popup='Laurelhurst Park',
color='#3186cc',
fill=True,
fill_color='#3186cc'
).add_to(wuhan_map)
# 获取点的经纬度
# wuhan_map.add_child(folium.LatLngPopup())
# 动态添加标签
wuhan_map.add_child(folium.ClickForMarker(popup='Waypoint'))
7.查找武汉科技大学
import foliumposition = [30.4415, 114.2628] # 武科大的经纬度school_mp = folium.Map(location=position,zoom_start=15)school_mp
8.未解决
弹出pop_up显示图片不会。
9.参考文章
转载:https://blog.csdn.net/weixin_45750972/article/details/117088924
查看评论