Concensus
Concensus is a gem for reading the United States Census Bureau's TIGER/Line Shapefiles.
It uses the georuby gem to convert the shapefiles, which leaves you with access to all of the methods in the georuby API.
Install
gem 'concensus'
Use
Concensus::Place.find("CA", "Berkeley")
=> #<Concensus::Place>
Concensus::Place.find_all("CA")
=> [#<Concensus::Place>, #<Concensus::Place>, etc...]
Concensus::configuration.year = 2011
=> all subsequent requests will be for 2011
Concensus::Place.find("NY", "New York")
=> 2011 Boundaries for New York City
Concensus::configuration.year = 2010
california = Concensus::State.find("CA")
california.geometry
=> #<GeoRuby::SimpleFeatures::MultiPolygon>
california.geometry.to_array
=> [[[-119.000932, 33.535895], [-119.000932, 33.535823], [-118.997845, 33.534199], [-118.994453, 33.532711], [-118.992796, 33.531849], [-118.990046, 33.530288999999996], [-118.986199, 33.527425], ...], ...]
california.geometry.to_array[0]
=> [[-119.000932, 33.535895], [-119.000932, 33.535823], ... ]
List of Resources
2011 | 2010 | |
---|---|---|
Concensus::Congressional | ✓ | |
Concensus::County | ✓ | |
Concensus::Place | ✓ | ✓ |
Concensus::School::Elementary | ✓ | ✓ |
Concensus::School::Secondary | ✓ | ✓ |
Concensus::School::Unified | ✓ | ✓ |
Concensus::State | ✓ | |
Concensus::StateLegislative::Upper | ✓ | ✓ |
Concensus::StateLegislative::Lower | ✓ | ✓ |
Concensus::Zipcode | ✓ |
Full Documentation
http://rubydoc.info/github/adamjacobbecker/concensus/
Notes
Some of the .zip files downloaded are quite large, so this gem requires temporary storage to unzip and cache the downloaded files. By default, we store these in ~/.concensus/tmp/
.
If you're using Rails, you'll probably want to create an initializer with Concensus.configure { |c| c.tmp_dir = "#{Rails.root}/tmp/concensus/" }
. This way, you can use Concensus with the (very temporary) writable storage on Heroku.
Todo
- Add more geographic areas, we only have a small bit of what's available.
- Add support for storing downloaded and uncompressed .zips on S3. (Heroku has no persistent writable file storage.)
Support development by sending links to siiick house mixes: @AdamJacobBecker