class USGeo::County
County
or county equivalent. Counties are composed of zero or more ZCTA's and may belong to a CBSA. The county's significance withing the CBSA is indicated by the central flag which indicates if it is a central or outlying county.
Public Class Methods
load!(uri = nil)
click to toggle source
# File lib/us_geo/county.rb, line 44 def load!(uri = nil) location = data_uri(uri || "counties.csv") import! do load_data_file(location) do |row| load_record!(geoid: row["GEOID"]) do |record| record.gnis_id = row["GNIS ID"] record.name = row["Name"] record.short_name = row["Short Name"] record.state_code = row["State"] record.cbsa_geoid = row["CBSA"] record.metropolitan_division_geoid = row["Metropolitan Division"] record.dma_code = row["DMA"] record.time_zone_name = row["Time Zone"] record.fips_class_code = row["FIPS Class"] record.central = (row["Central"] == "T") 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"]) record.lat = row["Latitude"] record.lng = row["Longitude"] end end end end
Public Instance Methods
county_fips()
click to toggle source
# File lib/us_geo/county.rb, line 76 def county_fips geoid[2, 3] end
metropolitan_area()
click to toggle source
Return the CBSA only if it is a metropolitan area.
# File lib/us_geo/county.rb, line 81 def metropolitan_area core_based_statistical_area if core_based_statistical_area && core_based_statistical_area.metropolitan? end
state_fips()
click to toggle source
# File lib/us_geo/county.rb, line 72 def state_fips geoid[0, 2] end
time_zone()
click to toggle source
# File lib/us_geo/county.rb, line 85 def time_zone ActiveSupport::TimeZone[time_zone_name] if time_zone_name end