Created
May 3, 2012 18:47
-
-
Save leesmith/2588050 to your computer and use it in GitHub Desktop.
Basic geokit geocoding
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'geokit' | |
require 'csv' | |
Geokit::Geocoders::google = 'your_key' | |
places = CSV.read('places.csv', headers: true) | |
places.each do |p| | |
street = p.fields[4] | |
city_state = [p.fields[5], p.fields[6]].join(',') | |
zip = p.fields[7] | |
address = [street, city_state, zip].join(' ') | |
geo = Geokit::Geocoders::GoogleGeocoder.geocode address | |
lat, long = geo.ll.split(',') | |
puts address + ' => ' + 'Lat: ' + lat + ' Long: ' + long | |
sleep 2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment