Python 使用folium繪制leaflet地圖的實(shí)現(xiàn)方法
leaflet為R語(yǔ)言提供了API很好用,這次嘗試用Python使用leaflet,需要folium
安裝folium
pip install folium
一個(gè)小例子
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
準(zhǔn)備的數(shù)據(jù)
| |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地圖的實(shí)現(xiàn)方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Python?列表中的刪除操作之del、remove?和?pop?的區(qū)別
在Python中,列表(list)是一種非常靈活的數(shù)據(jù)結(jié)構(gòu),它允許我們存儲(chǔ)一系列的元素,在刪除元素時(shí),我們可以使用三種不同的方法:del、remove?和?pop,每種方法都有其特定的用途和行為,了解它們的區(qū)別可以幫助我們更有效地使用列表,感興趣的朋友跟隨小編一起看看吧2024-05-05Python multiprocessing.Manager介紹和實(shí)例(進(jìn)程間共享數(shù)據(jù))
這篇文章主要介紹了Python multiprocessing.Manager介紹和實(shí)例(進(jìn)程間共享數(shù)據(jù)),本文介紹了Manager的dict、list使用例子,同時(shí)介紹了namespace對(duì)象,需要的朋友可以參考下2014-11-11Python實(shí)現(xiàn)簡(jiǎn)單字典樹(shù)的方法
這篇文章主要介紹了Python實(shí)現(xiàn)簡(jiǎn)單字典樹(shù)的方法,實(shí)例分析了Python字典樹(shù)的定義、實(shí)現(xiàn)與使用技巧,需要的朋友可以參考下2016-04-04Python 讀寫(xiě) Matlab Mat 格式數(shù)據(jù)的操作
這篇文章主要介紹了Python 讀寫(xiě) Matlab Mat 格式數(shù)據(jù)的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-05-05Python中摘要算法MD5,SHA1簡(jiǎn)介及應(yīng)用實(shí)例代碼
這篇文章主要介紹了Python中摘要算法MD5,SHA1簡(jiǎn)介及應(yīng)用實(shí)例代碼,具有一定借鑒價(jià)值,需要的朋友可以參考下2018-01-01Python實(shí)現(xiàn)爬取房源信息的示例詳解
站在一個(gè)租房人的立場(chǎng),租房平臺(tái)實(shí)在太多了,并且各平臺(tái)篩選和排序邏輯都不太一致。這篇文章將教教大家如何利用Python語(yǔ)言實(shí)現(xiàn)爬取房源信息,需要的可以參考一下2022-09-09Python?threading和Thread模塊及線程的實(shí)現(xiàn)
這篇文章主要介紹了Python?threading和Thread模塊及線程的實(shí)現(xiàn),Python通過(guò)兩個(gè)標(biāo)準(zhǔn)庫(kù)thread和threading提供對(duì)線程的支持,threading對(duì)thread進(jìn)行了封裝,具體實(shí)現(xiàn)介紹需要的朋友可以參考一下下面文章內(nèi)容2022-06-06