import pandas as pd
import folium
#读取保存了GPS位置的文件
df = pd.read_csv("TEST002.csv",encoding = 'gb2312')
#处理经度
df1 = (df.iloc[:,4] - int(df.iloc[:,4][0]/100)*100)/60 + int(df.iloc[:,4][0]/100)
#处理纬度
df2 = (df.iloc[:,3] - int(df.iloc[:,3][0]/100)*100)/60 + int(df.iloc[:,3][0]/100)
group_A_jingdu = df1[df.iloc[:,2] == 'A']
group_A_weidu = df2[df.iloc[:,2] == 'A']
group_B_jingdu = df1[df.iloc[:,2] == 'B']
group_B_weidu = df2[df.iloc[:,2] == 'B']
group_C_jingdu = df1[df.iloc[:,2] == 'C']
group_C_weidu = df2[df.iloc[:,2] == 'C']
group_A_df3 = pd.DataFrame({'latitude':group_A_weidu,'longitude':group_A_jingdu})
group_B_df3 = pd.DataFrame({'latitude':group_B_weidu,'longitude':group_B_jingdu})
group_C_df3 = pd.DataFrame({'latitude':group_C_weidu,'longitude':group_C_jingdu})
#dataframe转为列表
group_A_df4 = group_A_df3.values.tolist()
group_B_df4 = group_B_df3.values.tolist()
group_C_df4 = group_C_df3.values.tolist()
import math
def get_C_coordinate(A, B, d):
x1, y1 = A
x2, y2 = B
d = d
AB = (x2 - x1, y2 - y1)
AB_len = math.sqrt(AB[0] ** 2 + AB[1] ** 2)
u = (AB[0] / AB_len, AB[1] / AB_len)
BC_len = d
theta = math.pi / 2
cos_t = math.cos(theta)
sin_t = math.sin(theta)
BC_x = u[0] * cos_t - u[1] * sin_t
BC_y = u[0] * sin_t + u[1] * cos_t
BC = (BC_x * BC_len, BC_y * BC_len)
x_c, y_c = x2 + BC[0], y2 + BC[1]
return x_c, y_c
def get_D_coordinate(A, B, d):
x1, y1 = A
x2, y2 = B
d = d
AB = (x2 - x1, y2 - y1)
AB_len = math.sqrt(AB[0] ** 2 + AB[1] ** 2)
u = (AB[0] / AB_len, AB[1] / AB_len)
BC_len = d
theta = math.pi / 2
cos_t = math.cos(theta)
sin_t = math.sin(theta)
BC_x = u[0] * cos_t - u[1] * sin_t
BC_y = u[0] * sin_t + u[1] * cos_t
BC = (BC_x * BC_len, BC_y * BC_len)
x_c, y_c = x2 - BC[0], y2 - BC[1]
return x_c, y_c
group_A_C_list = []
group_A_D_list = []
group_A_df3.index = range(len(group_A_df3))
for i in range(0,len(group_A_df3)-1):
A = [group_A_df3['latitude'][i], group_A_df3['longitude'][i]]
B = [group_A_df3['latitude'][i+1],group_A_df3['longitude'][i+1]]
d = 0.0001
C = get_C_coordinate(A, B, d)
my_list_C = list(C)
group_A_C_list.append(my_list_C)
print(B)
for i in range(0,len(group_A_df3)-1):
A = [group_A_df3['latitude'][i], group_A_df3['longitude'][i]]
B = [group_A_df3['latitude'][i+1],group_A_df3['longitude'][i+1]]
d = 0.0001
D = get_D_coordinate(A, B, d)
my_list_D = list(D)
group_A_D_list.append(my_list_D)
group_B_C_list = []
group_B_D_list = []
group_B_df3.index = range(len(group_B_df3))
for i in range(0,len(group_B_df3)-1):
A = [group_B_df3['latitude'][i], group_B_df3['longitude'][i]]
B = [group_B_df3['latitude'][i+1],group_B_df3['longitude'][i+1]]
d = 0.0001
C = get_C_coordinate(A, B, d)
my_list_C = list(C)
group_B_C_list.append(my_list_C)
for i in range(0,len(group_B_df3)-1):
A = [group_B_df3['latitude'][i], group_B_df3['longitude'][i]]
B = [group_B_df3['latitude'][i+1],group_B_df3['longitude'][i+1]]
d = 0.0001
D = get_D_coordinate(A, B, d)
my_list_D = list(D)
group_B_D_list.append(my_list_D)
group_C_C_list = []
group_C_D_list = []
group_C_df3.index = range(len(group_C_df3))
for i in range(0,len(group_C_df3)-1):
A = [group_C_df3['latitude'][i], group_C_df3['longitude'][i]]
B = [group_C_df3['latitude'][i+1],group_C_df3['longitude'][i+1]]
d = 0.0001
C = get_C_coordinate(A, B, d)
my_list_C = list(C)
group_C_C_list.append(my_list_C)
for i in range(0,len(group_C_df3)-1):
A = [group_C_df3['latitude'][i], group_C_df3['longitude'][i]]
B = [group_C_df3['latitude'][i+1],group_C_df3['longitude'][i+1]]
d = 0.0001
D = get_D_coordinate(A, B, d)
my_list_D = list(D)
group_C_D_list.append(my_list_D)
group_A_C_data = group_A_C_list
group_A_D_data = group_A_D_list
group_B_C_data = group_B_C_list
group_B_D_data = group_B_D_list
group_C_C_data = group_C_C_list
group_C_D_data = group_C_D_list
# 将整个二维列表反转
reversed_r_group_A_D_data = list(reversed(group_A_D_data))
group_A_CD = group_A_C_data + reversed_r_group_A_D_data
group_A_CD.append(group_A_C_data[0])
# 将整个二维列表反转
reversed_r_group_B_D_data = list(reversed(group_B_D_data))
group_B_CD = group_B_C_data + reversed_r_group_B_D_data
group_B_CD.append(group_B_C_data[0])
# 将整个二维列表反转
reversed_r_group_C_D_data = list(reversed(group_C_D_data))
group_C_CD = group_C_C_data + reversed_r_group_C_D_data
group_C_CD.append(group_C_C_data[0])
### 绘制地图 ####
m = folium.Map(group_A_df4[0], zoom_start=15,position='absolutely', attr='default',zoom_control=True) #中心区域的确定
folium.PolyLine(
group_A_df4,
weight=3,
color='red',
opacity=0.8,
).add_to(m)
# 起始点,结束点
folium.Marker(group_A_df4[0], popup='<b>Starting Point</b>').add_to(m)
folium.Marker(group_A_df4[-1], popup='<b>End Point</b>').add_to(m)
ll = folium.PolyLine(locations = group_A_CD,
color='black',
opacity=0.8,
fill=True,
fill_color='#111111')
folium.PolyLine(
group_B_df4,
weight=3,
color='blue',
opacity=0.8
).add_to(m)
folium.Marker(group_B_df4[0], popup='<b>Starting Point</b>').add_to(m)
folium.Marker(group_B_df4[-1], popup='<b>End Point</b>').add_to(m)
ls = folium.PolyLine(locations = group_B_CD,
color='orange',
opacity=0.8,
fill=True,
fill_color='#111111')
folium.PolyLine(
group_C_df4,
weight=3,
color='blue',
opacity=0.8
).add_to(m)
folium.Marker(group_C_df4[0], popup='<b>Starting Point</b>').add_to(m)
folium.Marker(group_C_df4[-1], popup='<b>End Point</b>').add_to(m)
ls = folium.PolyLine(locations = group_C_CD,
color='red',
opacity=0.8,
fill=True,
fill_color='#111111')
ls.add_to(m)
ll.add_to(m)
m
朽木自雕i
- 粉丝: 1w+
- 资源: 24
最新资源
- 圣诞人物卡通动物园小学课件模板.pptx
- 手绘汽球小太阳小学教学课件教案模板.pptx
- 小学低年级暑假生活模板.pptx
- 考虑时变压力角和时变齿侧间隙的直齿轮六自由度平移-扭转耦合非线性动力学程序,包括时域图,相图,FFT图,庞加莱图,分岔图 要想学好齿轮动力学,需要有扎实的齿轮动力学理论和非线性动振动理论 齿轮啮合
- 一款基于.Net WinForm的节点编辑器 纯GDI+绘制 使用方式非常简洁 提供了丰富的属性以及事件 可以非常方便的完成节点之间数据的交互及通知 大量的虚函数供开发者重写具有很高的自由性.zip
- 中国百年百名中医临床家丛书 干祖望.pdf
- 中国所有学校地理位置Json数据库(省市区地址,坐标)(分校区,大学,中学,小学等等)(Python爬虫).zip
- 毕业设计基于 U-Net 网络的遥感图像语义分割.rar
- 圆盘光弹条纹中心线的定级GUI(MATLAB).zip
- 基于labview的声卡数据采集系统与分析设计毕业论文
- 中国高校计算机大赛-大数据挑战赛,Rank24 解决方案.zip
- 基于声卡的LabVIEW数据采集与分析系统设计毕业论文
- 基于巴特莱特窗设计滤波器实现语音去噪
- stm32f103c8t6软件spi驱动st7735s屏幕
- STM32低成本简化版的MD500E变频器代码,永磁同步电机控制算法代码 相比于原版代码删除了一些功能接口,算法部分没有删减,用在STM32低成本方案中,更精简、易读; 代码包含了参数辨识、死区补偿、
- 云南大数据交通.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈