-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkmlconverter-lowflights.py
73 lines (60 loc) · 2.27 KB
/
kmlconverter-lowflights.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
67
68
69
70
71
72
73
import simplekml
import sys
path='dump1090-127_0_0_1-1907261.txt'
inputpath = input("Pfad?")
if inputpath != "":
path = inputpath
rawdata = open(path,'r')
airplanes = []
airplanedata = []
num_lines = sum(1 for line in open(path,'r'))
print("Reading Data... FOUND "+str(num_lines)+" LINES")
for line in rawdata:
line = line.rstrip()
line = line.split(',')
#CHECK IF PLANE EXISTS
if line[0] in airplanes:
planeindex = airplanes.index(line[0])
else:
airplanes.append(line[0])
airplanedata.append([])
planeindex = airplanes.index(line[0])
airplanedata[planeindex].append(line)
print("Finished!!!")
print("Found "+str(len(airplanes)-1)+" airplanes in Data")
print("===ALL AIRPLANES BY HEXIDENT===")
index=0
for plane in airplanes:
if index > 0:
print(str(index)+". "+plane)
index+=1
maxheight = input("Maximale Höhe?")
#KML POINT GENERATOR
kmlpoint = simplekml.Kml()
style = simplekml.Style()
style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png'
for i in range(0, len(airplanedata)):
for datarow in airplanedata[i]:
if datarow[1] != "altitude(meter)" and int(datarow[1]) < int(maxheight):
pnt = kmlpoint.newpoint()
pnt.name=""
pnt.description = datarow[11]+" "+datarow[4]+" "+datarow[5]+" "+datarow[0]+" Höhe:"+datarow[1]+" Lat. "+datarow[2]+" Long. "+datarow[3]
pnt.coords = [(datarow[3],datarow[2],datarow[1])]
pnt.style = style
pnt.altitudemode = simplekml.AltitudeMode.relativetoground
filename = input("Dateiname?")
kmlpoint.save(filename+"_POINTS.kml")
#KML LINE GENERATOR
kml = simplekml.Kml()
for i in range(0, len(airplanedata)):
planecoords=[]
for datarow in airplanedata[i]:
if datarow[1] != "altitude(meter)" and int(datarow[1]) < int(maxheight):
planecoords.append((datarow[3],datarow[2],datarow[1]))
#print(planecoords)
lin = kml.newlinestring(name=airplanedata[i][0][11],
description=airplanedata[i][0][4]+" "+airplanedata[i][0][5]+" "+airplanedata[i][0][0],
coords=planecoords)
lin.extrude = 0
lin.altitudemode = simplekml.AltitudeMode.relativetoground
kml.save(filename+"_LINES.kml")