0

I am trying to plot a point for an aircraft at about 1000m. The docs say that I can add it after the coords but it is not working. I am using Jupyter but here is my code. When I add no data after the coords it puts the point on the ground. When I add the height after the coords it does the same. It does not seem to change anything.

import simplekml
import csv
import pandas

csv_dir = 'C:\Data\Merg_Convert\Output'
csv_in = csv_dir + '\\' + 'Consol.csv'

colnames = ['Time','Freq','ATTN','RSSI','AZ','PlatLat','PlatLon','SourceLat',
            'SourceLon','CellipMaj','CellipMin','CellipTilt','Comments','EndLat','EndLong']
ROUND = 4

data = pandas.read_csv(csv_in, names=colnames)
freqs = data.Freq.tolist()
freqs.pop(0)
[float(i) for i in freqs]
round_ = [round(float(num), ROUND) for num in freqs]
res = [] 
[res.append(x) for x in round_ if x not in res] 
print('Done') #This kicks back a warning but not sure how to stop it. 

def build_kml(freq):
    kml=simplekml.Kml()
    kml_out = csv_dir + '\\KML\\' + str(freq) + '.kml'
    inputfile = csv.reader(open(csv_in,'r'))
    for row in inputfile:
        if row[1] != 'Freq(MHz)':
            rnd_ = round(float(row[1]), ROUND)
            if rnd_ == freq:
                if row[8] != '':
                    kml.newpoint(name=row[1], coords=[(row[8],row[7])])

                pnt = kml.newpoint()
                pnt.coords = [(row[6],row[5],1000.0)] #This is the issue
                pnt.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/airports.png'

                ls = kml.newlinestring(name=row[1])
                ls.coords = [(row[6],row[5],5000), (row[14],row[13],0)]

                ls.altitudemode = simplekml.AltitudeMode.relativetoground
                ls.style.linestyle.width = 1
                ls.style.linestyle.color = simplekml.Color.blue

    kml.save(kml_out)

for f in res:
    build_kml(f)

This is an example of my data.

['Time', 'Freq(MHz)', 'ATTN(dB)', 'RSSI(dBm)', 'AZ(deg)', 'PlatLat', 'PlatLon', 'SourceLat', 'SourceLon', 'CellipMaj(m)', 'CellipMin(m)', 'CellipTilt(deg)', 'Comments', 'EndLat', 'EndLong']
['2020-02-20 08:40:26Z', '190.591', '18', '-67.4', '53', '32.814603', '66.015223', '32.815613', '66.016815', '125', '111.5', '-48.7', 'Point1', '33.298794', '66.787735']
['2020-02-20 08:40:27Z', '190.591', '18', '-67.4', '53', '32.814603', '66.015223', '32.815613', '66.016815', '125', '111.5', '-48.7', 'Point2', '33.298794', '66.787735']
['2020-02-20 08:40:28Z', '190.591', '18', '-66.4', '54.8', '32.814967', '66.015294', '32.815797', '66.016694', '125', '107.7', '-52.8', 'Point3', '33.278522', '66.805527']
['2020-02-20 08:40:29Z', '190.591', '18', '-66.9', '58.7', '32.815151', '66.015326', '32.815909', '66.016809', '125', '122.6', '65.7', 'Point4', '33.232468', '66.841217']

2 Answers2

1

I know it's an old question.... but just in case.... I think you need to add the altitudemode to the point. You've only done it for the linestring as it is shown here. i.e. pnt.altitudemode = simplekml.AltitudeMode.relativetoground

Abe
  • 11
  • 1
0

By default SimpleKML tells Google Earth to clamp the points to ground even if you are providing the altitude value. As Abe mentioned you need to change this default behavior using pnt.altitudemode = simplekml.AltitudeMode.relativetoground. Ref: https://simplekml.readthedocs.io/en/latest/tut_linestring.html

ENEG
  • 1