-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_plots.py
70 lines (56 loc) · 1.84 KB
/
run_plots.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
65
66
67
68
69
70
import os
import sys
import folium as fl
import datetime as dt
import pandas as pd
# --- --- ---
# Run Params
projDir = "/Users/peteraltamura/Documents/fun/plunkett/location/"
fname = "locations.csv"
outpath = "/Users/peteraltamura/Documents/fun/output/"
# --- --- ---
# Run
df_coords = pd.read_csv(projDir+fname)
print(df_coords.head())
# Instantiate Map
map = fl.Map()
# Begin Iterating over coordinates dataframe
locs = []
for i in range(df_coords.shape[0]):
print(df_coords[['Lat', 'Lon']].iloc[i])
# Unpack Coordinates
convLat = float(df_coords['Lat'].iloc[i].split("-")[0]) + \
(float(df_coords['Lat'].iloc[i].split("-")[1][:2])/60)
if df_coords['Lat'].iloc[i][-1:]=='S':
convLat *= -1
convLon = float(df_coords['Lon'].iloc[i].split("-")[0]) + \
(float(df_coords['Lon'].iloc[i].split("-")[1][:2])/60)
if df_coords['Lon'].iloc[i][-1:]=='W':
convLon *= -1
# add to locs
locs.append((convLat, convLon))
# Unpack Date
date_ = df_coords['Date'].iloc[i]
# Unpack time
time_ = df_coords['Time'].iloc[i]
# Unpack Notes
notes = df_coords['Notes'].iloc[i] if str(df_coords['Notes'].iloc[i]) \
!= 'nan' else ''
print(convLat, convLon, notes)
html_ = """
<div class="header">
<h1>{}-{} USS Plunkett Log Notes</h1>
</div>
""".format(date_, time_)
popup_ = fl.Popup(fl.IFrame(html=html_+notes, width=400, height=250), max_width=2650)
# Make Marker
currMarker = fl.Marker(
[convLat, convLon],
icon=fl.Icon(color='red', icon='hospital-symbol', prefix='fa'),
popup=popup_
).add_to(map)
# Add Line
journey = fl.PolyLine(locs, color='red', weight=8, opacity=0.6).add_to(map)
if not os.path.exists(outpath):
os.makedirs(outpath)
map.save(outpath+"PlunkettChart.html")