Class: USGeo::UrbanArea

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

Overview

Urban areas are split into either urbanized areas (population > 50,000) or urban cluster (population < 50,000).

Direct Known Subclasses

UrbanCluster, UrbanizedArea

Constant Summary

Constants inherited from BaseRecord

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

Instance Attribute Summary

Attributes included from Population

#housing_units, #population

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 Population

#housing_density, #housing_density_km, #population_density, #population_density_km

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



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/us_geo/urban_area.rb', line 66

def load!(uri = nil)
  location = data_uri(uri || "urban_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) ? "UrbanizedArea" : "UrbanCluster")
        record.name = row["Name"]
        record.short_name = row["Short Name"]
        record.primary_county_geoid = row["Primary County GEOID"]
        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

#cluster?Boolean

Return true if the population is less than 50,000.

Returns:

  • (Boolean)


98
99
100
# File 'lib/us_geo/urban_area.rb', line 98

def cluster?
  population < 50_000
end

#urbanized?Boolean

Return true if the population is greater than or equal to 50,000.

Returns:

  • (Boolean)


91
92
93
# File 'lib/us_geo/urban_area.rb', line 91

def urbanized?
  population >= 50_000
end