Skip to content

Instantly share code, notes, and snippets.

@tylerpearson
Last active December 29, 2015 02:39
Show Gist options
  • Save tylerpearson/7601973 to your computer and use it in GitHub Desktop.
Save tylerpearson/7601973 to your computer and use it in GitHub Desktop.
Durham health inspection data with coordinates as geoJSON https://github.com/codefordurham/Durham-Data/tree/master/Restaurants
require 'pp'
require 'active_support/all'
# require 'colored'
require 'json'
results = JSON.parse(File.read("../json/raw/dump-data-science.json"))
geo_json = {
:type => "FeatureCollection",
:features => []
}
results.each_with_index do |location, index|
puts location['premise_name_titlecase']
unless location['premise_name_titlecase'] == "Oh! Brian's"
venue = {
:type => "Feature",
:id => location['est_id'],
:geometry => {
:type => "Point",
:coordinates => [location['geo_results']['results'][0]['geometry']['location']['lng'], location['geo_results']['results'][0]['geometry']['location']['lat']]
},
:properties => location.except!("geo_results")
}
# venue = {
# :type => "Point",
# :coordinates => [location['geo_results']['geometry']['location']['lng'], location['geo_results']['geometry']['location']['lat']]
# }
geo_json[:features] << venue
end
end
pp geo_json.to_json
File.open("../json/formatted/dump-data-science.json","w") do |f|
f.write(geo_json.to_json)
end
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment