我一直在尝试使用点坐标在 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>
的值必须是 clampToGround 或 clampToSeaFloor 否则镶嵌标志将被忽略。
确保生成的 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/