Skip to content

Instantly share code, notes, and snippets.

@leesmith
Created May 3, 2012 18:47
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 leesmith/2588050 to your computer and use it in GitHub Desktop.
Save leesmith/2588050 to your computer and use it in GitHub Desktop.
Basic geokit geocoding
#!/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