python - 使用 SimpleKML 绘制大圆

标签 python kml google-earth simplekml

我一直在尝试使用点坐标在 Google 地球上绘制一些线条,一切正常,但只有一个小细节。这些线穿过地球并且不跟随表面,所以它们通常是不可见的,因为我在全局各地都有点。有什么想法吗?

line = kml.newlinestring(coords=[firstcoord, secondcoord])

提前致谢:)

最佳答案

您需要启用 tesselate在线几何形状上以遵循地球的曲率。

Very large lines should enable tessellation so that they follow the curvature of the earth (otherwise, they may go underground and be hidden).

要启用曲面分割,<altitudeMode> 的值必须是 clampToGroundclampToSeaFloor 否则镶嵌标志将被忽略。

确保生成的 KML 输出如下所示:

  <Placemark>
    <name>line with tessellation</name>
    <LineString>
      <tessellate>1</tessellate>
      <altitudeMode>clampToGround</altitudeMode>
      <coordinates>
        -122.383103,37.617112 -73.782201,40.643612 
      </coordinates>
    </LineString>
  </Placemark>

执行此操作的 Python 代码:

import simplekml

kml = simplekml.Kml()
firstcoord = (-122.383103, 37.617112)
secondcoord = (-73.782201, 40.643612)
line = kml.newlinestring(tessellate=1,
                         altitudemode=simplekml.AltitudeMode.clamptoground,
                         coords=[firstcoord, secondcoord])

print("Output: line.kml")
kml.save("line.kml")

关于python - 使用 SimpleKML 绘制大圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20663715/

相关文章:

python - pandas:根据其他列乘以列

C# - 查找坐标以将线延长一定公里数

python - 在 iter 上并行化循环

Python cProfile 结果似乎没有加起来

KML 网络链接 - 飞到

php - 让 map 接受动态生成的 KML 文件?

sql - 在 SQL 2008 中生成 KML

javascript - Google Earth API 按地标名称搜索

java - 将卫星图像或 map 集成到 3D 应用程序中

python - 平行图中相同的 Y 轴