-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
64 lines (48 loc) · 1.87 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 22 05:21:14 2019
@author: tanma
"""
import rl
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
data = pd.read_csv('no.csv')
data = data.drop(['time','Unnamed: 0'],axis = 1)
subset = data.loc[data["track_id"] == 27]
vector = subset.iloc[-10,:-1]
speed = [vector[0]]
direction = [vector[3]]
newcoords = [[vector[2],vector[1]]]
for i in range(20):
x = rl.speed(vector)
y = rl.direction(vector)
z = list(rl.NewCoords(vector))[:2]
speed.append(x)
direction.append(y)
newcoords.append(z)
vector = [x,z[1],z[0],y]
comp_df = pd.DataFrame()
comp_df['lat_pred'] = np.array(newcoords)[1:,0]
comp_df['long_pred'] = np.array(newcoords)[1:,1]
comp_df['lat_actual'] = np.array(subset.iloc[-10:,2])
comp_df['long_actual'] = np.array(subset.iloc[-10:,1])
comp_df['var_lat'] = comp_df['lat_pred'] - comp_df['lat_actual']
comp_df['var_long'] = comp_df['long_pred'] - comp_df['long_actual']
print(comp_df.head())
ax = plt.plot(subset.iloc[3000:-10,1],subset.iloc[3000:-10,2], color='red')
plt.plot(np.array(newcoords)[:,1],np.array(newcoords)[:,0], color='blue')
plt.plot(comp_df['long_actual'],comp_df['lat_actual'],color='black')
plt.show()
def plot_on_map(latlon):
import folium
mapit = folium.Map( location=[subset.iloc[-10,2],subset.iloc[-10,1]], zoom_start=6 )
for coord in range(len(latlon)):
if coord >4:
folium.Marker( location=[ latlon[coord][0], latlon[coord][1]], fill_color='#43d9de', radius=8 ).add_to( mapit)
else:
folium.Marker( location=[ latlon[coord][0], latlon[coord][1]], fill_color='#3186cc', radius=8 ).add_to( mapit)
mapit.save('map.html')
cords = list(zip(list(comp_df['lat_pred']),list(comp_df['long_pred'])))
plot_on_map(cords + list(zip(list(comp_df['lat_actual']),list(comp_df['long_actual']))))