Class: USGeo::UrbanAreaCounty

Inherits:
BaseRecord
  • Object
show all
Includes:
Demographics
Defined in:
lib/us_geo/urban_area_county.rb

Overview

Mapping of urban areas 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

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/urban_area_county.rb', line 21

def load!(uri = nil)
  location = data_uri(uri || "urban_area_counties.csv")
  
  import! do
    load_data_file(location) do |row|
      load_record!(urban_area_geoid: row["Urban Area GEOID"], county_geoid: row["County 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_areaObject

Percentage of the county land area.



58
59
60
# File 'lib/us_geo/urban_area_county.rb', line 58

def percent_county_land_area
  land_area / county.land_area
end

#percent_county_populationObject

Percentage of the county population.



53
54
55
# File 'lib/us_geo/urban_area_county.rb', line 53

def percent_county_population
  population.to_f / county.population.to_f
end

#percent_county_total_areaObject

Percentage of the county total area.



63
64
65
# File 'lib/us_geo/urban_area_county.rb', line 63

def percent_county_total_area
  total_area / county.total_area
end

#percent_urban_area_land_areaObject

Percentage of the urban area land area.



43
44
45
# File 'lib/us_geo/urban_area_county.rb', line 43

def percent_urban_area_land_area
  land_area / urban_area.land_area
end

#percent_urban_area_populationObject

Percentage of the urban area population.



38
39
40
# File 'lib/us_geo/urban_area_county.rb', line 38

def percent_urban_area_population
  population.to_f / urban_area.population.to_f
end

#percent_urban_area_total_areaObject

Percentage of the urban area total area.



48
49
50
# File 'lib/us_geo/urban_area_county.rb', line 48

def percent_urban_area_total_area
  total_area / urban_area.total_area
end