kml connect placemarks with a solid line

时间:2017-08-05 10:30:45

标签: python google-maps maps line kml

i've written a kml file full of placemarks with name, description and coordinates. It's structure is like this:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
  <name>test</name>
  <description><![CDATA[test]]></description>
        <Placemark>
            <name>name 1</name>
            <description>description 1</description>
            <Point>
                <coordinates>18.70669,36.12645</coordinates>
            </Point>
        </Placemark>

        <Placemark>
            <name>name 2</name>
            <description>description 2</description>
            <Point>
                <coordinates>18.70513,36.12698</coordinates>
            </Point>
        </Placemark>
</Document>
</kml>

The only way I found to connect them is by using <MultiGeometry><LineString><coordinates> but I'm looking for a smarter and smaller solution. A python script would be accepted as a solution too.

1 个答案:

答案 0 :(得分:0)

如果我正确理解了这一点,那么你要做的就是用一条线连接两个坐标?如果是这样,您只需使用<LineString>

<LineString id="geom_842">
    <coordinates>18.70669,36.12645,0.0 18.70513,36.12698,0.0 </coordinates>
</LineString>

使用documentation中的python:

import simplekml
kml = simplekml.Kml()
lin = kml.newlinestring(name="name", description="description",
      coords=[(18.70669,36.12645), (18.70513,36.12698)])
kml.save('filename.kml')