Python 使用folium绘制leaflet地图的实现方法

yipeiwu_com5年前Python基础

leaflet为R语言提供了API很好用,这次尝试用Python使用leaflet,需要folium

安装folium

pip install folium

一个小例子

import folium
import re

input = open('C:\\Users\\Administrator\\Desktop\\a.txt','r')
text=input.read()
list = re.split('\n',text)
location = []
for element in list:
  location.append([re.split('\|',element)[3],re.split('\|',element)[4]])
oneUserMap = folium.Map(location=[40.07645623466996,116.27861671489337],zoom_start=12)
i=1
for e in location:
  folium.RegularPolygonMarker(
  [e[0],e[1]],
  popup=str(i)+":"+e[0]+e[1],
  fill_color='#769d96',
  number_of_sides=8,
  radius=10
  ).add_to(oneUserMap)
  i+=1
line_to_hanoi = folium.PolyLine(
  location
  color = black
).add_to(oneUserMap)
oneUserMap

准备的数据

| |1501496792778|40.07645623466996 |116.27861671489337|   |500.0      |
| |1501496804436|40.07677430790909 |116.30160665327273|   |500.0      |
| |1501496811915|40.07955491668396 |116.30727382008362|   |648.4      |
| |1501496812482|40.06855637583342 |116.30051482871957|   |500.0      |
| |1501496813846|40.077435394999995|116.30485216   |   |500.0      |
| |1501496817141|40.077584649928994|116.307341000568 |   |500.0      |
| |1501496822612|40.06655521627066 |116.31470252233457|   |500.0      |
| |1501496827068|40.07608486533642 |116.31106972109029|   |500.0      |
| |1501496836593|40.06973485515626 |116.30804128929688|   |500.0      |
| |1501496845777|40.06760852730224 |116.30944094027082|   |500.0      |
| |1501496848437|40.069649238   |116.311817496   |   |500.0      |
| |1501496856231|40.058194078836195|116.32216476281336|   |500.0      |
| |1501496861028|40.063267583333335|116.31401683333334|   |1343.0      |
| |1501496861941|40.06892254545454 |116.30769918181818|   |500.0      |
| |1501496874235|39.95851709299716 |116.33535910323356|   |500.0      |
| |1501496883656|40.05552336712328 |116.33116400410958|   |545.6712328767123|
| |1501496884418|39.95247840268642 |116.27639847967654|   |782.4242424242424|
| |1501496887172|40.05552336712328 |116.33116400410958|   |545.6712328767123|
| |1501496889896|40.0629648236   |116.3135063834914 |   |500.0      |
| |1501496906523|40.06657995649843 |116.31431445005182|   |500.0      |
| |1501496917442|40.05858427795066 |116.31701011815242|   |500.0      |
| |1501496923937|40.05771468790228 |116.32008644656291|   |500.0      |
| |1501496932527|40.03028229460086 |116.33105832998122|   |588.7      |

以上这篇Python 使用folium绘制leaflet地图的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

在python中pandas的series合并方法

如下所示: In [3]: import pandas as pd In [4]: a = pd.Series([1,2,3]) In [5]: b = pd.Series(...

介绍Python中的fabs()方法的使用

 方法fabs()返回 x 的绝对值。 语法 以下是fabs()方法的语法: import math math.fabs( x ) 注意:此函数是无法直接访问的,所...

Python实现定时备份mysql数据库并把备份数据库邮件发送

一、先来看备份mysql数据库的命令 mysqldump -u root --password=root --database abcDataBase > c:/abc_bac...

python实现植物大战僵尸游戏实例代码

python实现植物大战僵尸游戏实例代码

开发思路 完整项目地址:https://github.com/371854496/... 觉得还OK的话,点下Star,作者不易,thank you! 实现方法 1.引入需要的模...

python集合用法实例分析

本文实例讲述了python集合用法。分享给大家供大家参考。具体分析如下: # sets are unordered collections of unique hashable el...