Class: USGeo::ZctaPlace
- Inherits:
-
BaseRecord
- Object
- ActiveRecord::Base
- BaseRecord
- USGeo::ZctaPlace
- Includes:
- Area
- Defined in:
- lib/us_geo/zcta_place.rb
Overview
Mapping of ZCTA’s to places they overlap with.
Constant Summary
Constants inherited from BaseRecord
BaseRecord::STATUS_IMPORTED, BaseRecord::STATUS_MANUAL, BaseRecord::STATUS_REMOVED
Instance Attribute Summary
Attributes included from Area
Attributes inherited from BaseRecord
Class Method Summary collapse
Instance Method Summary collapse
-
#percent_place_land_area ⇒ Object
Percentage of the place land area.
-
#percent_place_population ⇒ Object
Percentage of the place population.
-
#percent_place_total_area ⇒ Object
Percentage of the place 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 Area
#land_area_km, #percent_land, #total_area, #water_area_km
Methods inherited from BaseRecord
#imported?, #manual?, #removed?
Class Method Details
.load!(uri = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/us_geo/zcta_place.rb', line 17 def load!(uri = nil) location = data_uri(uri || "zcta_places.csv") import! do load_data_file(location) do |row| load_record!(zipcode: row["ZCTA5"], place_geoid: row["Place GEOID"]) do |record| record.land_area = row["Land Area"] record.water_area = row["Water Area"] end end end end |
Instance Method Details
#percent_place_land_area ⇒ Object
Percentage of the place land area.
52 53 54 |
# File 'lib/us_geo/zcta_place.rb', line 52 def percent_place_land_area land_area / place.land_area end |
#percent_place_population ⇒ Object
Percentage of the place population.
47 48 49 |
# File 'lib/us_geo/zcta_place.rb', line 47 def percent_place_population population.to_f / place.population.to_f end |
#percent_place_total_area ⇒ Object
Percentage of the place total area..
57 58 59 |
# File 'lib/us_geo/zcta_place.rb', line 57 def percent_place_total_area total_area / place.total_area end |
#percent_zcta_land_area ⇒ Object
Percentage of the ZCTA land area.
37 38 39 |
# File 'lib/us_geo/zcta_place.rb', line 37 def percent_zcta_land_area land_area / zcta.land_area end |
#percent_zcta_population ⇒ Object
Percentage of the ZCTA population.
32 33 34 |
# File 'lib/us_geo/zcta_place.rb', line 32 def percent_zcta_population population.to_f / zcta.population.to_f end |
#percent_zcta_total_area ⇒ Object
Percentage of the ZCTA total area.
42 43 44 |
# File 'lib/us_geo/zcta_place.rb', line 42 def percent_zcta_total_area total_area / zcta.total_area end |