Skip to content

Instantly share code, notes, and snippets.

@ckdake
Created April 24, 2012 13:53
Show Gist options
  • Save ckdake/2479821 to your computer and use it in GitHub Desktop.
Save ckdake/2479821 to your computer and use it in GitHub Desktop.
Google Earth KML to a heathamp
import heatmap # http://jjguy.com/heatmap/
import random
import csv
if __name__ == "__main__":
pts = []
for point in csv.reader(open('coords.csv')):
pts.append((float(point[0]), float(point[1])))
print "Processing %d points..." % len(pts)
hm = heatmap.Heatmap()
hm.heatmap(pts, "heatmap.png", 25, 128, (8192,8192))
hm.saveKML("heatmap.kml")
require 'nokogiri' # gem install nokogiri
@doc = Nokogiri::XML(File.open("my.kml"))
@doc.css('coordinates').each do |coordinates|
coordinates.text.split(' ').each do |coordinate|
(lat,lon,elevation) = coordinate.split(',')
puts "#{lat},#{lon}\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment