Class: USGeo::UrbanAreaCounty

Inherits:
BaseRecord
  • Object
show all
Includes:
Area
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

Instance Attribute Summary

Attributes included from Area

#land_area, #water_area

Attributes inherited from BaseRecord

#status, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

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

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.land_area = row["Land Area"]
        record.water_area = row["Water Area"]
      end
    end
  end
end

Instance Method Details

#percent_county_land_areaObject

Percentage of the county land area.



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

def percent_county_land_area
  land_area / county.land_area
end

#percent_county_total_areaObject

Percentage of the county total area.



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

def percent_county_total_area
  total_area / county.total_area
end

#percent_urban_area_land_areaObject

Percentage of the urban area land area.



32
33
34
# File 'lib/us_geo/urban_area_county.rb', line 32

def percent_urban_area_land_area
  land_area / urban_area.land_area
end

#percent_urban_area_total_areaObject

Percentage of the urban area total area.



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

def percent_urban_area_total_area
  total_area / urban_area.total_area
end