-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosgr_to_osgb36.py
44 lines (28 loc) · 903 Bytes
/
osgr_to_osgb36.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
import pandas
import numpy
from osgr_to_osgb36_data import corrections
input_file = ''
output_file = ''
data = pandas.read_csv(input_file, low_memory=False)
# create new fields to store new coordinates
data['e'] = numpy.nan
data['n'] = numpy.nan
i = 0
for index, row in data.iterrows():
if isinstance(row['NG LETTERS'], str):
correction_e = corrections[row['NG LETTERS']]['E']
correction_n = corrections[row['NG LETTERS']]['N']
e = str(row['EASTING']).replace('.0','')
n = str(row['NORTHING']).replace('.0','')
while len(e) < 4:
e = '0' + e
while len(n) < 4:
n = '0' + n
e = e + '0'
n = n + '0'
e = correction_e + e
n = correction_n + n
data.at[index,'e'] = e
data.at[index,'n'] = n
# write output file
data.to_csv(output_file)