Class: USGeo::ZctaCounty
- Inherits:
-
BaseRecord
- Object
- ActiveRecord::Base
- BaseRecord
- USGeo::ZctaCounty
- Includes:
- Demographics
- Defined in:
- lib/us_geo/zcta_county.rb
Overview
Mapping of ZCTA’s to counties they overlap with.
Constant Summary
Constants inherited from BaseRecord
BaseRecord::STATUS_IMPORTED, BaseRecord::STATUS_MANUAL, BaseRecord::STATUS_REMOVED
Class Method Summary collapse
Instance Method Summary collapse
-
#percent_county_land_area ⇒ Object
Percentage of the county land area.
-
#percent_county_population ⇒ Object
Percentage of the county population.
-
#percent_county_total_area ⇒ Object
Percentage of the county total area.
-
#percent_zcta_land_area ⇒ Object
Percentage of the ZCTA land area.
-
#percent_zcta_population ⇒ Object
Percentage of the ZCTA population.
-
#percent_zcta_total_area ⇒ Object
Percentage of the ZCTA total area.
Methods included from Demographics
#percent_land, #population_density, #total_area
Methods inherited from BaseRecord
#imported?, #manual?, #removed?
Class Method Details
.load!(uri = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/us_geo/zcta_county.rb', line 21 def load!(uri = nil) location = data_uri(uri || "zcta_counties.csv") import! do load_data_file(location) do |row| load_record!(zipcode: row["ZCTA5"], county_geoid: row["GEOID"]) do |record| record.population = row["Population"] record.housing_units = row["Housing Units"] record.land_area = area_meters_to_miles(row["Land Area"]) record.water_area = area_meters_to_miles(row["Water Area"]) end end end end |
Instance Method Details
#percent_county_land_area ⇒ Object
Percentage of the county land area.
58 59 60 |
# File 'lib/us_geo/zcta_county.rb', line 58 def percent_county_land_area land_area / county.land_area end |
#percent_county_population ⇒ Object
Percentage of the county population.
53 54 55 |
# File 'lib/us_geo/zcta_county.rb', line 53 def percent_county_population population.to_f / county.population.to_f end |
#percent_county_total_area ⇒ Object
Percentage of the county total area.
63 64 65 |
# File 'lib/us_geo/zcta_county.rb', line 63 def percent_county_total_area total_area / county.total_area end |
#percent_zcta_land_area ⇒ Object
Percentage of the ZCTA land area.
43 44 45 |
# File 'lib/us_geo/zcta_county.rb', line 43 def percent_zcta_land_area land_area / zcta.land_area end |
#percent_zcta_population ⇒ Object
Percentage of the ZCTA population.
38 39 40 |
# File 'lib/us_geo/zcta_county.rb', line 38 def percent_zcta_population population.to_f / zcta.population.to_f end |
#percent_zcta_total_area ⇒ Object
Percentage of the ZCTA total area.
48 49 50 |
# File 'lib/us_geo/zcta_county.rb', line 48 def percent_zcta_total_area total_area / zcta.total_area end |