为什么 Google 地球会更改 KML 多边形坐标?
Why is Google Earth changing KML polygon coordinates?
我的目标是能够使用 KML 文件在 google earth 中的定义区域上绘制阴影多边形。我创建了一个包含一个地标和一个具有所需坐标的多边形的 KML 文档,并且能够将文件导入 Google 我的地图并显示该多边形。但是,当我用 google earth 打开同一个文件时,坐标似乎被不同地解析并且多边形不正确(见图)。我的 KML 文件中是否遗漏了导致 google earth 执行此操作的某些内容?
这些是原始文件坐标。
<coordinates>
149.02126, -36.489864, 100
149.3816, -36.31477, 100
149.25783, -36.134285, 100
148.9647, -36.4074, 100
149.02126, -36.489864, 100
</coordinates>
如果我从 google earth 复制多边形并将其作为 KML 粘贴到文本文件中,我会得到以下坐标
<coordinates>
149.02126,-36.489864,100
149.3816,0,0
-36.31477,100,0
149.25783,-36.134285,100
148.9647,-36.4074,100
149.02126,-36.489864,100
</coordinates>
完整的原始 KML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="examplePolyStyle">
<PolyStyle>
<color>7f0000ff</color>
<colorMode>random</colorMode>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<Placemark>
<name>ID: AU201502070705001Issued: 2015-02-07T07:53:00.000Z</name>
<description>Begins: 2015-02-07T07:53:00.000ZEnds: 2015-02-07T08:38:00.000Z</description>
<styleUrl>#examplePolyStyle</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>149.02126, -36.489864, 100 149.3816, -36.31477, 100 149.25783, -36.134285, 100 148.9647, -36.4074, 100 149.02126, -36.489864, 100</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
从 Google 地球
复制的完整 KML 文件
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>Latest_Single_noCommaNoSpaces.kml</name>
<Style id="examplePolyStyle">
<PolyStyle>
<color>7f0000ff</color>
<colorMode>random</colorMode>
</PolyStyle>
</Style>
<Placemark>
<name>ID: AU201502070705001Issued: 2015-02-07T07:53:00.000Z</name>
<description>Begins: 2015-02-07T07:53:00.000ZEnds: 2015-02-07T08:38:00.000Z</description>
<styleUrl>#examplePolyStyle</styleUrl>
<gx:balloonVisibility>1</gx:balloonVisibility>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
149.02126,-36.489864,100
149.3816,0,0
-36.31477,100,0
149.25783,-36.134285,100
148.9647,-36.4074,100
149.02126,-36.489864,100
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
您的原始 KML 坐标在元组中有空格,that is not valid(空格 分隔 个元组)。
<coordinates>
(required)
Four or more tuples, each consisting of floating point values for longitude, latitude, and altitude. The altitude component is optional. Do not include spaces within a tuple. The last coordinate must be the same as the first coordinate. Coordinates are expressed in decimal degrees only.
<coordinates>149.02126, -36.489864, 100 149.3816, -36.31477, 100 149.25783, -36.134285, 100 148.9647, -36.4074, 100 149.02126, -36.489864, 100</coordinates>
应该是:
<coordinates>149.02126,-36.489864,100 149.3816,-36.31477,100 149.25783,-36.134285,100 148.9647,-36.4074,100 149.02126,-36.489864,100</coordinates>
我的目标是能够使用 KML 文件在 google earth 中的定义区域上绘制阴影多边形。我创建了一个包含一个地标和一个具有所需坐标的多边形的 KML 文档,并且能够将文件导入 Google 我的地图并显示该多边形。但是,当我用 google earth 打开同一个文件时,坐标似乎被不同地解析并且多边形不正确(见图)。我的 KML 文件中是否遗漏了导致 google earth 执行此操作的某些内容?
这些是原始文件坐标。
<coordinates>
149.02126, -36.489864, 100
149.3816, -36.31477, 100
149.25783, -36.134285, 100
148.9647, -36.4074, 100
149.02126, -36.489864, 100
</coordinates>
如果我从 google earth 复制多边形并将其作为 KML 粘贴到文本文件中,我会得到以下坐标
<coordinates>
149.02126,-36.489864,100
149.3816,0,0
-36.31477,100,0
149.25783,-36.134285,100
148.9647,-36.4074,100
149.02126,-36.489864,100
</coordinates>
完整的原始 KML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="examplePolyStyle">
<PolyStyle>
<color>7f0000ff</color>
<colorMode>random</colorMode>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<Placemark>
<name>ID: AU201502070705001Issued: 2015-02-07T07:53:00.000Z</name>
<description>Begins: 2015-02-07T07:53:00.000ZEnds: 2015-02-07T08:38:00.000Z</description>
<styleUrl>#examplePolyStyle</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>149.02126, -36.489864, 100 149.3816, -36.31477, 100 149.25783, -36.134285, 100 148.9647, -36.4074, 100 149.02126, -36.489864, 100</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
从 Google 地球
复制的完整 KML 文件<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>Latest_Single_noCommaNoSpaces.kml</name>
<Style id="examplePolyStyle">
<PolyStyle>
<color>7f0000ff</color>
<colorMode>random</colorMode>
</PolyStyle>
</Style>
<Placemark>
<name>ID: AU201502070705001Issued: 2015-02-07T07:53:00.000Z</name>
<description>Begins: 2015-02-07T07:53:00.000ZEnds: 2015-02-07T08:38:00.000Z</description>
<styleUrl>#examplePolyStyle</styleUrl>
<gx:balloonVisibility>1</gx:balloonVisibility>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
149.02126,-36.489864,100
149.3816,0,0
-36.31477,100,0
149.25783,-36.134285,100
148.9647,-36.4074,100
149.02126,-36.489864,100
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
您的原始 KML 坐标在元组中有空格,that is not valid(空格 分隔 个元组)。
<coordinates>
(required)
Four or more tuples, each consisting of floating point values for longitude, latitude, and altitude. The altitude component is optional. Do not include spaces within a tuple. The last coordinate must be the same as the first coordinate. Coordinates are expressed in decimal degrees only.
<coordinates>149.02126, -36.489864, 100 149.3816, -36.31477, 100 149.25783, -36.134285, 100 148.9647, -36.4074, 100 149.02126, -36.489864, 100</coordinates>
应该是:
<coordinates>149.02126,-36.489864,100 149.3816,-36.31477,100 149.25783,-36.134285,100 148.9647,-36.4074,100 149.02126,-36.489864,100</coordinates>