Module: USGeo::Demographics
- Included in:
- CombinedStatisticalArea, CoreBasedStatisticalArea, County, CountySubdivision, MetropolitanDivision, Place, UrbanArea, UrbanAreaCounty, Zcta, ZctaCounty, ZctaPlace, ZctaUrbanArea
- Defined in:
- lib/us_geo/demographics.rb
Overview
This module is mixed into all models. Note that the area given for land and water is in square miles.
Instance Method Summary collapse
-
#percent_land ⇒ Object
The fraction of the area that is composed of land instead of water.
-
#population_density ⇒ Object
Population per square mile.
-
#total_area ⇒ Object
Total area of both land an water in square miles.
Instance Method Details
#percent_land ⇒ Object
The fraction of the area that is composed of land instead of water.
20 21 22 |
# File 'lib/us_geo/demographics.rb', line 20 def percent_land land_area / total_area if land_area end |
#population_density ⇒ Object
Population per square mile.
10 11 12 |
# File 'lib/us_geo/demographics.rb', line 10 def population_density population.to_f / land_area if population && land_area end |
#total_area ⇒ Object
Total area of both land an water in square miles
15 16 17 |
# File 'lib/us_geo/demographics.rb', line 15 def total_area land_area.to_f + water_area.to_f if land_area end |