Class: USGeo::CoreBasedStatisticalArea

Inherits:
BaseRecord
  • Object
show all
Includes:
Area, Population
Defined in:
lib/us_geo/core_based_statistical_area.rb

Overview

Core based statistical area composed of one or more counties anchored by an urban center. Includes both metropolitan (population > 50,000) and micropolitan (population > 10,000 but < 50,000) areas.

Direct Known Subclasses

MetropolitanArea, MicropolitanArea

Constant Summary

Constants inherited from BaseRecord

BaseRecord::STATUS_IMPORTED, BaseRecord::STATUS_MANUAL, BaseRecord::STATUS_REMOVED

Instance Attribute Summary collapse

Attributes included from Area

#land_area, #water_area

Attributes included from Population

#housing_units, #population

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 included from Population

#housing_density, #housing_density_km, #population_density, #population_density_km

Methods inherited from BaseRecord

#imported?, #manual?, #removed?

Instance Attribute Details

#geoidString

Returns 5-digit code for the CBSA.

Returns:

  • (String)

    5-digit code for the CBSA.



# File 'lib/us_geo/core_based_statistical_area.rb', line 29

#nameString

Returns Name of the CBSA.

Returns:

  • (String)

    Name of the CBSA.



# File 'lib/us_geo/core_based_statistical_area.rb', line 32

Class Method Details

.load!(uri = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/us_geo/core_based_statistical_area.rb', line 39

def load!(uri = nil)
  location = data_uri(uri || "core_based_statistical_areas.csv")

  import! do
    load_data_file(location) do |row|
      load_record!(geoid: row["GEOID"]) do |record|
        record.type = ((row["Population"].to_i >= 50_000) ? "MetropolitanArea" : "MicropolitanArea")
        record.name = row["Name"]
        record.short_name = row["Short Name"]
        record.csa_geoid = row["CSA"]
        record.population = row["Population"]
        record.housing_units = row["Housing Units"]
        record.land_area = row["Land Area"]
        record.water_area = row["Water Area"]
        record.lat = row["Latitude"]
        record.lng = row["Longitude"]
      end
    end
  end
end

Instance Method Details

#metropolitan?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


61
62
63
# File 'lib/us_geo/core_based_statistical_area.rb', line 61

def metropolitan?
  raise NotImplementedError
end

#micropolitan?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


65
66
67
# File 'lib/us_geo/core_based_statistical_area.rb', line 65

def micropolitan?
  raise NotImplementedError
end