I hereby claim:
- I am rywall on github.
- I am rywall (https://keybase.io/rywall) on keybase.
- I have a public key ASBA1dWlR7lwE7osmOivioSsalsiwSjvKerE4QakDLPH2go
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env ruby | |
require 'csv' | |
Dir.chdir File.dirname(__FILE__) | |
class String | |
def green; "\e[32m#{self}\e[0m" end | |
def yellow; "\e[33m#{self}\e[0m" end | |
end |
en: | |
new: "New" | |
edit: "Edit" | |
delete: "Delete" | |
cancel: "Cancel" | |
import: "Import" | |
error: "Error" | |
toggle_navigation: "Toggle Navigation" |
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'rack', github: 'rack/rack' | |
gem 'i18n', github: 'svenfuchs/i18n' | |
gem 'sqlite3' | |
GEMFILE |
class CreateModels < ActiveRecord::Migration | |
def change | |
create_table :items do |t| | |
end | |
end | |
end | |
class Item < ActiveRecord::Base | |
end |
Item | Image path | Last Attempt |
---|---|---|
Awl Case - 50.67.36 | http://cdn2.brooklynmuseum.org/images/opencollection/objects/size3/50.67.59a-b_50.67.41_50.67.36_possibly_50.67.121_50.67.137_and+unknown_glass_bw.jpg |
# Calculate the intake fraction where iF = SUM(popDensN * DispN) | |
# where popDensN is the population density in an N meter buffer minus the previous buffer | |
def intake_fraction | |
fraction = 0 | |
inner_pop = 0 | |
inner_area = 0 | |
DISPERSION_FACTORS.each do |buffer, value| | |
pop_in_buffer = send("pop#{buffer}m").to_i | |
area_in_buffer = send("area#{buffer}m").to_i |
DISPERSION_FACTORS = {50 => 0.5341, 100 => 0.3610, 200 => 0.5145, 500 => 0.9159, 1000 => 0.9088, 5000 => 4.662} | |
# Calculate the intake fraction where iF = SUM(popN * DispN) / 1000 | |
# where popN is the population in an N meter buffer minus the previous population buffer | |
def intake_fraction | |
fraction = 0 | |
inner_pop = 0 | |
DISPERSION_FACTORS.each do |buffer, value| | |
pop_in_buffer = send("pop#{buffer}m").to_i | |
fraction += (pop_in_buffer - inner_pop) * value * 0.62 * 14.5 |
[50, 100, 200, 500, 1000, 5000].each do |buffer| | |
puts "Calculating population within #{buffer} m of each shape_geometry" | |
Shape.find_each do |s| | |
execute "UPDATE shapes SET pop#{buffer}m = | |
(SELECT SUM((ST_SummaryStats(ST_Clip(rast,1,ST_Buffer(geom::geography, #{buffer})::geometry))).sum) | |
FROM shapes, population_tiles | |
WHERE id = #{s.id} AND ST_Intersects(ST_Buffer(geom::geography, #{buffer})::geometry,rast) | |
GROUP BY id) | |
WHERE id = #{s.id}" | |
end |