【问题标题】:kml connect placemarks with a solid linekml 用实线连接地标
【发布时间】:2017-08-05 10:30:44
【问题描述】:

我编写了一个kml 文件,其中包含名称、描述和坐标的地标。它的结构是这样的:

<?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>

我发现连接它们的唯一方法是使用&lt;MultiGeometry&gt;&lt;LineString&gt;&lt;coordinates&gt;,但我正在寻找更智能、更小的解决方案。 也可以接受 python 脚本作为解决方案。

【问题讨论】:

  • 为什么不能直接使用&lt;MultiGeometry&gt;&lt;LineString&gt;&lt;coordinates&gt;

标签: python google-maps maps line kml


【解决方案1】:

如果我理解正确,那么您要做的就是将两个坐标用一条线连接起来?如果是这样,您需要做的就是使用&lt;LineString&gt;

<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')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多