0

我有以下带有站点 A 和站点 B 坐标的 csv 文件。我想使用 Python 在站点 A 和站点 B 之间绘制一条路径。以下是csv文件。

    Site A          Site B  
Site A  Lat Long    Site B  Lat Long
PRGR     53.906969° -122.788618°    TABR     53.906319° -122.452036°
TABR     53.906319° -122.452036°    HIXN     53.470608° -122.630719°
HIXN     53.470608° -122.630719°    DRGN     52.883608° -122.339258°
DRGN     52.883608° -122.339258°    POTA     52.301208° -121.841503°
POTA     52.301208° -121.841503°    TIMO     51.904336° -121.251706°
LIME     51.093293° -121.665607°    SAVO     50.699822° -120.816183°
SAVO     50.699822° -120.816183°    IRON     50.047728° -120.757496°
IRON     50.047728° -120.757496°    TUK  50.464231° -119.581204°
IRON     50.047728° -120.757496°    THYN     49.702183° -120.922895°
TUK  50.464231° -119.581204°    SILV     50.369695° -119.063741°
TUK  50.464231° -119.581204°    RUTL     49.915597° -119.318128°
RUTL     49.915597° -119.318128°    KELW     49.876475° -119.451763°
TIMO     51.904336° -121.251706°    LIME     51.093293° -121.665607°

在此处输入图像描述

这是我的代码,但没有绘制线条。

import csv
import simplekml


inputfile = csv.reader(open('FBCRN.csv',encoding="utf8", errors='ignore'))
kml=simplekml.Kml()
next(inputfile)
next(inputfile)

for row in inputfile:
    
    lin = kml.newlinestring(name=row[0], coords=[(row[2],row[1]), (row[5], row[4])])
    lin.style.linestyle.color = 'ff0000ff'  # Red
    lin.style.linestyle.width= 10  # 10 pixels    
kml.save('FBG.kml')
4

0 回答 0