Created
April 24, 2012 13:53
-
-
Save ckdake/2479821 to your computer and use it in GitHub Desktop.
Google Earth KML to a heathamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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