【小沐学GIS】Google的kml文件的读写(C++、Python)

1、简介

https://developers.google.cn/kml/documentation/kmzarchives?hl=zh-cn

1.1 kml简介

KML 是一种文件格式,用于在地球浏览器(例如 Google 地球、Google 地图和 Google 地图移动版)中显示地理数据。KML 使用包含嵌套的元素和属性的结构(基于标记),并符合 XML 标准。所有标记都区分大小写,并且必须与 KML 参考中列出的完全一样。该参考指出了哪些标记是可选的。在给定元素内,标记必须按照参考中列出的顺序显示。
在这里插入图片描述
Google 地球和 Google 地图可以直接读取 KML 和 KMZ 文件,并可将文件保存为 KMZ 格式。默认情况下,主 KML 文件名为 doc.kml。
在这里插入图片描述
KMZ 文件包含主 KML 文件以及0个或多个用 ZIP 格式打包成一个单元的支持文件(称为归档)。
一个KMZ文件的内容结构可能如下:
在这里插入图片描述

1.2 功能点

1.2.1 地标

地标是 Google 地球中最常用的地图项之一。它使用黄色图钉作为图标,在地球表面标记位置。最简单的地标只包含一个 元素,用于指定地标的地点。您可以指定地标的名称和自定义图标,还可以为地标添加其他几何元素。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Placemark>
        <name>爱看书的杨小羊</name>
        <description>Attached to the ground. Intelligently places itself at the height of the underlying terrain.</description>
        <Point>
            <coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
        </Point>
    </Placemark>
</kml>
  • 3d地球上加载kml文件显示如下:

在这里插入图片描述

1.2.2 地面叠加层

通过地面叠加层,您可在 Google 地球的地形上“叠加”图片。 元素包含指向叠加图片 .jpg 文件的链接。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Folder>
        <name>爱看书的杨小羊</name>
        <description>Examples of ground overlays</description>
        <GroundOverlay>
            <name>Large-scale overlay on terrain</name>
            <description>Overlay shows Mount Etna erupting on July 13th, 2001.</description>
            <Icon>
                <href>http://developers.google.com/kml/documentation/images/etna.jpg</href>
            </Icon>
            <LatLonBox>
                <north>37.91904192681665</north>
                <south>37.46543388598137</south>
                <east>15.35832653742206</east>
                <west>14.60128369746704</west>
                <rotation>-0.1556640799496235</rotation>
            </LatLonBox>
        </GroundOverlay>
    </Folder>
</kml> 
  • 3d地球上加载kml文件显示如下:

在这里插入图片描述

1.2.3 路径

可以在 Google 地球中创建多种不同类型的路径,并且可轻松地利用您的数据充分发挥创造力。在 KML 中,路径是用 元素创建的。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
    <Document>
        <name>Paths</name>
        <description>Examples of paths. Note that the tessellate tag is by default
 set to 0. If you want to create tessellated lines, they must be authored
 (or edited) directly in KML.</description>
        <Style id="yellowLineGreenPoly">
            <LineStyle>
                <color>7f00ffff</color>
                <width>4</width>
            </LineStyle>
            <PolyStyle>
                <color>7f00ff00</color>
            </PolyStyle>
        
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值