0

我正在尝试为大约 1000m 的飞机绘制一个点。文档说我可以在坐标之后添加它,但它不起作用。我正在使用 Jupyter,但这是我的代码。当我在坐标之后不添加任何数据时,它会将点放在地面上。当我在坐标之后添加高度时,它也是如此。它似乎没有改变任何东西。

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)

这是我的数据的一个例子。

['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']
4

1 回答 1

1

我知道这是一个老问题....但以防万一....我认为您需要将高度模式添加到这一点。您只为线串完成了它,如此处所示。即 pnt.altitudemode = simplekml.AltitudeMode.relativetoground

于 2021-05-18T21:12:37.507 回答