Skip to content

Instantly share code, notes, and snippets.

@lenagroeger
Created June 18, 2014 17:20
Show Gist options
  • Save lenagroeger/d6c06b649ae85fc0054e to your computer and use it in GitHub Desktop.
Save lenagroeger/d6c06b649ae85fc0054e to your computer and use it in GitHub Desktop.
geocode some cities
# task :bundlegeocode => :environment do
# require 'goog_geocoder'
# factory = ::RGeo::Geographic.simple_mercator_factory()
# f = CSV.open("#{Rails.root.to_s}/db/initial/bundlecities.csv", :headers => true)
# f.each do |row|
# city = row["city"]
# state = row["state"]
# goog = GoogGeocoder.new("#{city},#{state}")
# if !goog.resp["results"].empty?
# accuracy = goog.resp["results"].first["geometry"]["location_type"]
# geometry = goog.resp["results"].first["geometry"]["location"]
# location = factory.point(geometry["lng"],geometry["lat"])
# puts "#{city}, #{state}, #{geometry["lng"]}, #{geometry["lat"]}"
# end
# end
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment