Skip to content

Instantly share code, notes, and snippets.

Created February 25, 2011 19:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
from xml.etree.ElementTree import ElementTree
import urllib
source_url = ''
source = urllib.urlopen(source_url)
tree = ElementTree()
doc = tree.parse(source)
print'<?xml version="1.0" encoding="UTF-8"?>'
print '<kml xmlns="">'
#print ','.join(['"%s"' % k for k in ['id', 'creator', 'program', 'url', 'lat', 'lng', 'dtype', 'description']])
for marker in doc:
id = marker.attrib['id']
creator = marker.attrib['creator']
program = marker.attrib['program']
url = marker.attrib['url']
lat = marker.attrib['lat']
lng = marker.attrib['lng']
dtype = marker.attrib['type']
description = '<h1>%s</h1><a href=\"%s\">Link</a>' % (creator, url)
print "<Placemark>"
print "<name>%s</name>" % creator
print '<description><![CDATA[%s]]></description>' % description
print '<Point>'
print '<coordinates>%s, %s,0</coordinates>' % (lat, lng)
print '</Point>'
print '</Placemark>'
print '</kml>'
Copy link

dhapi breakout. Working with lat and long from Montana State's dissertation collection. Creating KML to load into Google Earth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment