Created
June 18, 2014 17:20
-
-
Save lenagroeger/d6c06b649ae85fc0054e to your computer and use it in GitHub Desktop.
geocode some cities
This file contains hidden or 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
| # 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