-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReproject.py
More file actions
54 lines (39 loc) · 1.68 KB
/
Reproject.py
File metadata and controls
54 lines (39 loc) · 1.68 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
'''//www.python.org/dev/peps/pep-0008/ '''
''' standard library imports '''
import time
''' related third party imports '''
import numpy as np
from pyproj import Proj
from optparse import OptionParser
''' local application/library specific imports '''
import geoidReader
def reproject(options):
'''
Rounding
http://gis.stackexchange.com/questions/8650/how-to-measure-the-accuracy-of-latitude-and-longitude
'''
startTime = time.time()
inputData = np.loadtxt(options.inputFileName,delimiter=',',usecols=(0,1,2))
outputData = open(options.outputFileName,'w')
lon=inputData[:,0]
lat=inputData[:,1]
height=inputData[:,2]
offsetDict = geoidReader.loadOffsetDict()
proj = Proj(init=options.epsgCode)
X, Y = proj(lon,lat)
numPoints = inputData.shape[0]
for i in range(0,numPoints):
pointX,pointY,pointHeight,pointLon,pointLat = X[i],Y[i],height[i],lon[i],lat[i]
offset=geoidReader.computePointOffset(offsetDict,(pointLon,pointLat))
pointHeight -=offset
#Rounding down to save on space and improve I/O
outputData.write(str(round(pointX,4))+','+str(round(pointY,4))+','+str(round(pointHeight,4))+'\n')
outputData.close()
print(int(time.time()-startTime),' seconds runtime')
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-i','--inputFilePath', action="store", dest="inputFileName",help="Path to the input file")
parser.add_option('-o','--outputFilePath', action="store", dest="outputFileName",help="Path to the output file")
parser.add_option('--epsgCode', action="store", dest="epsgCode",help="EPSG code of the transform to use. For example, 'epsg:32756' is the code for UTM zone 56 South.")
(options, args) = parser.parse_args()
reproject(options)