我试图用python(使用simplekml)创建一个kml文件,其中包含连接这些点的点和线。我还想把点变成正方形,而不是默认的黄色图钉。在
现在我已经成功地创建了包含点或线的kml文件。但我想把这两个文件合并成一个文件。我正在从csv文件中读取文件。所以我想把这两个代码放在一起就能给我一条线和一个点,但事实并非如此。我只看到点。我错过了什么?在
inputfile = csv.reader(open(file, 'r'))
kml = simplekml.Kml()
ls = kml.newlinestring(name='A LineString')
ls.coords = np.array([[float(row[2]),float(row[1])] for row in inputfile ])
ls.extrude = 1
ls.altitudemode = simplekml.AltitudeMode.relativetoground
for row in inputfile:
kml.newpoint(name=row[0], coords=[(row[2], row[1])])
pnt.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/placemark_square.png'
kml.save("Points_and_Line.kml")
文件在第4行执行后位于末尾,因此第二个for循环在尝试创建点时迭代空列表。在
创建点时从文件中读取每行的坐标,并将坐标添加到可用于创建直线的列表中。在
相关问题 更多 >
编程相关推荐