Usando pyKML para analisar documentos KML

Estou usando o módulo pyKML para extrair coordenadas de um determinado arquivo KML.

Meu código Python é o seguinte:

from pykml import parser
fileobject = parser.fromstring(open('MapSource.kml', 'r').read())
root = parser.parse(fileobject).getroot()
print(xml.Document.Placemark.Point.coordinates)

No entanto, ao executar isso, recebo o seguinte erro:

ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.

Procurando soluções, me deparei com essa soluçãohttp://twigstechtips.blogspot.in/2013/06/python-lxml-strings-with-encoding.html de onde eu tentei isso (que não tenho certeza se é o método correto):

from pykml import parser
from lxml import etree
from os import path
kml_file = open('MapSource.kml', 'r')
parser = etree.XMLParser(recover=True)
xml = etree.fromstring(kml_file, parser)
print(xml.Document.Placemark.Point.coordinates)

Isso me dáValueError: can only parse strings. Qual é a maneira correta de analisar o KML e obter as coordenadas nessa estrutura?

questionAnswers(0)

yourAnswerToTheQuestion