0

Is there anyway to get the KML name and/or description fields using GDAL/OGR for Python? I can get the fields for the individual layers easily enough, just not for the entire thing.

Code is:

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

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

What's the best way to get the KML name/description fields?

Josh
  • 3,385
  • 5
  • 23
  • 45

1 Answers1

1

Easiest way is to use a separate Python XML parser rather than the GDAL/OGR package.

import xml.etree.ElementTree as ET

tree = ET.parse( file )
root = tree.getroot()
description = root[0][1].text
Josh
  • 3,385
  • 5
  • 23
  • 45