-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert2.py
66 lines (50 loc) · 1.85 KB
/
convert2.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
import pandas as pd
import numpy as np
from pyproj import Transformer
class Coords():
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def getCoords(self):
return self.x, self.y, self.z
def setCoords(self, x, y, z):
self.x = x
self.y = y
self.z = z
inputFile = "polylines_with_velocity_GK.csv"
outputFile = "transformed_" + inputFile
epsgIn = 'epsg:31467' # DHDN GK zone 3
epsgOut = 'epsg:4326' # WGS84
outputDims = 2
data = pd.read_csv(inputFile)# , usecols=[1,2,3,4,5,6,7], names=['x', 'y', 'z','R','G','B','ID'])
npd = data.to_numpy()
w = open(outputFile, "w", 16000000)
tmpString = ""
l = len(npd[1])
transformer = Transformer.from_crs(epsgIn, epsgOut)
for i in range(len(npd)):
# x and y are exchanged because DHDN uses Northing (y) and Easting (x)
C = Coords(npd[i][1], npd[i][0], npd[i][2])
if outputDims == 3:
c = transformer.transform(C.x,C.y,C.z)
else:
c = transformer.transform(C.x,C.y)
if l == 9:
tmpString = str(c[1]) + "," + str(c[0]) + "," + str(C.z) + "," + str(npd[i][3]) + \
"," + str(npd[i][4]) + "," + str(npd[i][5]) + \
"," + str(npd[i][6]) + "," + str(npd[i][7]) + "," + str(npd[i][8]) + "\n"
if l == 7:
tmpString = str(c[1]) + "," + str(c[0]) + "," + str(C.z) + "," + str(npd[i][3]) + \
"," + str(npd[i][4]) + "," + str(npd[i][5]) + \
"," + str(npd[i][6]) + "\n"
elif l == 6:
tmpString = str(c[1]) + "," + str(c[0]) + "," + str(C.z) + "," + \
str(npd[i][3]) + "," + str(npd[i][4]) + "," + str(npd[i][5]) + "\n"
elif l == 3:
tmpString = str(c[1]) + "," + str(c[0]) + "," + str(C.z) + "\n"
if i % 100 == 0:
print(str(i) + ": " + tmpString)
w.write(tmpString)
w.close()
print("end reached!")