【问题标题】:Python GDAL/OGR - get KML headersPython GDAL/OGR - 获取 KML 标头
【发布时间】:2015-09-04 18:33:34
【问题描述】:

是否可以使用 GDAL/OGR for Python 获取 KML 名称和/或描述字段?我可以很容易地获得各个层的字段,而不是整个事物。

代码是:

from osgeo import ogr
file = #path to file goes here

inDriver = ogr.GetDriverByName( 'KML' )
inDataSource = inDriver.Open( file )
inLayer = inDataSource.GetLayer()

获取 KML 名称/描述字段的最佳方式是什么?

【问题讨论】:

    标签: python kml gdal ogr


    【解决方案1】:

    最简单的方法是使用单独的 Python XML 解析器而不是 GDAL/OGR 包。

    import xml.etree.ElementTree as ET
    
    tree = ET.parse( file )
    root = tree.getroot()
    description = root[0][1].text
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-28
      • 2010-09-25
      相关资源
      最近更新 更多