Skip to content

Instantly share code, notes, and snippets.

@lawlesst
Created February 25, 2011 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawlesst/844374 to your computer and use it in GitHub Desktop.
Save lawlesst/844374 to your computer and use it in GitHub Desktop.
from xml.etree.ElementTree import ElementTree
import urllib
source_url = 'http://etd.lib.montana.edu/etd/view/locations-markers.php'
source = urllib.urlopen(source_url)
tree = ElementTree()
doc = tree.parse(source)
print'<?xml version="1.0" encoding="UTF-8"?>'
print '<kml xmlns="http://www.opengis.net/kml/2.2">'
#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>'
@lawlesst
Copy link
Author

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