-
Notifications
You must be signed in to change notification settings - Fork 1
/
norbert_to_bob.py
executable file
·45 lines (35 loc) · 1.22 KB
/
norbert_to_bob.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
#!/usr/bin/python3
import os
import pandas as pd
import sys
import utm
assert len(sys.argv) == 2
df = pd.read_csv(sys.argv[1])
# Strip whitespace from column headers
df.rename(inplace=True, columns=lambda x: x.strip())
# Get UTM coordinates
x = []
y = []
zone = []
for lat, lon in zip(df['lat'], df['lon']):
easting, northing, zone_number, zone_letter = utm.from_latlon(lat, lon)
# Save in mm
x.append(easting * 1000)
y.append(northing * 1000)
zone.append('%d%s' % (zone_number, zone_letter))
df['X [mm]'] = x
df['Y [mm]'] = y
df['UTM zone'] = zone
df['altitude'] *= 1000 # Convert to mm
# Rename the columns to correspond to what we use elsewhere + tidiness
df.rename(inplace=True, columns={
'gps quality': 'GPS quality', 'lat': 'Latitude', 'lon': 'Longitude',
'altitude': 'Z [mm]', 'roll': 'Roll [degrees]',
'pitch': 'Pitch [degrees]', 'yaw': 'Heading [degrees]',
'image name': 'Filename', 'timestamp': 'Timestamp [ms]'})
# Reorder for clarity
df = df.reindex(columns=[
'Timestamp [ms]', 'X [mm]', 'Y [mm]', 'Z [mm]', 'Heading [degrees]',
'Pitch [degrees]', 'Roll [degrees]', 'Filename', 'GPS quality', 'UTM zone'])
# Output to stdout
print(df.to_csv(index=False))