-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_heatmap.py
More file actions
56 lines (44 loc) · 1.31 KB
/
simple_heatmap.py
File metadata and controls
56 lines (44 loc) · 1.31 KB
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
import argparse
import glob
import os
import gpxpy
import matplotlib.pyplot as plt
def parse_args() -> argparse.Namespace:
args = argparse.ArgumentParser(description="Create a simple heatmap")
args.add_argument(
"--dir",
help="Path to directory containing files to parse to generate the heatmap",
default=os.getcwd(),
)
args.add_argument(
"--output_path",
help="Path to output the simple heatmap",
default="simple_heatmap.png",
)
return args.parse_args()
def main():
args = parse_args()
gpx_list = glob.glob(args.dir + "/*.gpx")
fig = plt.figure(facecolor="0.05")
ax = plt.Axes(
fig,
[0.0, 0.0, 1.0, 1.0],
)
ax.set_aspect("equal")
ax.set_axis_off()
fig.add_axes(ax)
for gpx_data in gpx_list:
lat = []
lon = []
with open(gpx_data, "r") as gpx_file:
gpx = gpxpy.parse(gpx_file)
for track in gpx.tracks:
for segment in track.segments:
for point in segment.points:
lat.append(point.latitude)
lon.append(point.longitude)
plt.plot(lon, lat, color="deepskyblue", lw=0.8, alpha=0.8)
plt.savefig(args.output_path)
plt.show()
if __name__ == "__main__":
main()