Python使用folium excel繪制point
使用folium excel 繪制point
制作內(nèi)容
- 根據(jù)氣象臺(tái)資料獲得的點(diǎn)進(jìn)行繪制
- 對(duì)一個(gè)特殊的點(diǎn)做特別的標(biāo)注
- 數(shù)據(jù)來源
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : map03.py
# @Author: huifer
# @Date : 2018/6/28
import pandas as pd
import math
import folium
def degree_conversion_decimal(x):
"""
度分轉(zhuǎn)換成十進(jìn)制
:param x: float
:return: integer float
"""
integer = int(x)
integer = integer + (x - integer) * 1.66666667
return integer
def distance(origin, destination):
"""
經(jīng)緯度計(jì)算兩點(diǎn)距離
:param origin:
:param destination:
:return:
"""
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371 # km
dlat = math.radians(lat2 - lat1)
dlon = math.radians(lon2 - lon1)
a = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.radians(lat1)) \
* math.cos(math.radians(lat2)) * math.sin(dlon / 2) * math.sin(dlon / 2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
d = radius * c
return d
# 數(shù)據(jù)準(zhǔn)備
data = pd.read_excel('SURF_CHN_MUL_HOR_STATION.xlsx')
# 修改成十進(jìn)制 以及保留1一位小數(shù)
data['經(jīng)度'] = data['經(jīng)度'].apply(degree_conversion_decimal)
data['緯度'] = data['緯度'].apply(degree_conversion_decimal)
data['觀測(cè)場(chǎng)拔海高度(米)'] = data['觀測(cè)場(chǎng)拔海高度(米)'].apply(lambda x: round(x, 1))
data['氣壓傳感器拔海高度(米)'] = data['氣壓傳感器拔海高度(米)'].apply(lambda x: round(x, 1))
# 保存新的文件
# data.to_csv('氣象站信息十進(jìn)制.csv')
data["距離杭州(km)"] = data.apply(lambda r: distance((r['緯度'], r['經(jīng)度']), (30.14, 120.1)), axis=1)
# print(data[data['距離杭州(km)']<100].sort_values('距離杭州(km)'))
# 選擇除了杭州以外的內(nèi)容
selected_st = data[data['距離杭州(km)'] < 100].sort_values('距離杭州(km)').iloc[1::]
# 展示地圖
# 提取數(shù)據(jù)
hzdata = data.ix[data['站名'] == '杭州', ['站名', '緯度', '經(jīng)度']]
myMap = folium.Map(location=[hzdata.iloc[0]['緯度'], hzdata.iloc[0]['經(jīng)度']])
icon_hz = dict(
prefix='fa', color='red', icon_color='darkred', icon='cny'
)
icon = folium.Icon(**icon_hz)
folium.Marker(
location=[hzdata.iloc[0]['緯度'], hzdata.iloc[0]['經(jīng)度']],
popup="杭州",
icon=icon
).add_to(myMap)
for i in range(len(selected_st)):
name = selected_st.iloc[i]['站名']
x = selected_st.iloc[i]['緯度']
y = selected_st.iloc[i]['經(jīng)度']
test = folium.Html(
'<b>name:{}</b></br> <b>x:{}</b></br> <b>y:{}</b></br>'.format(name, x, y),
script=True)
popup = folium.Popup(test, max_width=2650)
folium.Marker(
location=[x, y],
popup=popup,
).add_to(myMap)
myMap.save("test.html")
成果展示

總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接
- Python利用folium實(shí)現(xiàn)地圖可視化
- Python繪制地圖神器folium的新人入門指南
- python-地圖可視化組件folium的操作
- 利用Python的folium包繪制城市道路圖的實(shí)現(xiàn)示例
- Python 使用folium繪制leaflet地圖的實(shí)現(xiàn)方法
- python使用folium庫(kù)繪制地圖點(diǎn)擊框
- Python 線程池模塊之多線程操作代碼
- Python基礎(chǔ)之logging模塊知識(shí)總結(jié)
- Python協(xié)程asyncio模塊的演變及高級(jí)用法
- Python中zipfile壓縮包模塊的使用
- python process模塊的使用簡(jiǎn)介
- Python基礎(chǔ)之元編程知識(shí)總結(jié)
相關(guān)文章
全面分析Python的優(yōu)點(diǎn)和缺點(diǎn)
本篇文章給大家詳細(xì)分析了Python的優(yōu)點(diǎn)和缺點(diǎn)以及相關(guān)的優(yōu)勢(shì)劣勢(shì)分析,對(duì)此有興趣的朋友學(xué)習(xí)下。2018-02-02
講解如何利用 Python完成 Saga 分布式事務(wù)
這篇文章主要介紹了如何利用 Python 完成一個(gè) Saga 的分布式事務(wù),需要的朋友可以參考下面文章具體的內(nèi)容2021-09-09
Python使用Nocalhost并開啟debug調(diào)試的方法
Nocalhost是一種開發(fā)者工具,支持針對(duì)Kubernetes應(yīng)用程序進(jìn)行調(diào)試和部署,這篇文章主要介紹了Python怎么使用Nocalhost并開啟debug,需要的朋友可以參考下2023-04-04
python神經(jīng)網(wǎng)絡(luò)Densenet模型復(fù)現(xiàn)詳解
這篇文章主要為大家介紹了python神經(jīng)網(wǎng)絡(luò)Densenet模型復(fù)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05
python requests.post帶head和body的實(shí)例
今天小編就為大家分享一篇python requests.post帶head和body的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-01-01
Pandas數(shù)值排序 sort_values()的使用
本文主要介紹了Pandas數(shù)值排序 sort_values()的使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-07-07
Python?copy()與deepcopy()方法之間有什么區(qū)別
這篇文章主要介紹了Python中的copy()和deepcopy(),下面詳細(xì)介紹該內(nèi)容并附上詳細(xì)代碼,需要的朋友可以參考一下文章的具體內(nèi)容,希望對(duì)你有所幫助2022-10-10

