Skip to content

Instantly share code, notes, and snippets.

@uwekamper
Created June 7, 2012 20:28
Show Gist options
  • Save uwekamper/2891355 to your computer and use it in GitHub Desktop.
Save uwekamper/2891355 to your computer and use it in GitHub Desktop.
Export placemarks from KML-file
#!/usr/bin/python
import os, sys
import xml.etree.ElementTree as ET
tree = ET.parse("filename.kml")
places = list(tree.iter('{http://earth.google.com/kml/2.0}Placemark'))
print '"name", "longitude", "latidude", "elevation"'
for p in places:
name = p.find('{http://earth.google.com/kml/2.0}name').text
point = p.find('{http://earth.google.com/kml/2.0}Point')
coord= point.find('{http://earth.google.com/kml/2.0}coordinates')
print '%s,' % name, coord.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment