2015-02-10 61 views
0

我的目标是能够使用KML文件在谷歌地球上定义的区域上绘制阴影多边形。我创建了一个带有一个地标和一个具有所需坐标的多边形的KML文档,并且可以将该文件导入Google My maps并显示该多边形。但是,当我用google earth打开同一个文件时,坐标似乎被解析得不同,多边形不正确(请参见图像)。在我的KML文件中是否存在导致Google地球执行此操作的内容?Google地球为什么改变KML多边形坐标?

这些是原始文件坐标。

<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我得到以下坐标

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

完整的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> 
复制

Screenshot of polygon in Google Maps

Screenshot of same polygon in Google Earth

回答

2

你原来的KML坐标具有的元组,that is not valid(空格单独元组)空间。

<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> 
+0

感谢您解决这个问题,我非常感激。 – Matt 2015-02-10 17:35:31

相关问题