Class: USGeo::ZctaMapping

Inherits:
BaseRecord
  • Object
show all
Defined in:
lib/us_geo/zcta_mapping.rb

Overview

Mapping of ZIP codes to currently active ZCTA’s. The U.S. Postal Service maintains the list of active ZIP codes which can change as population moves around. New ZIP codes are created when a new area is developed and old ZIP are retired when an area is losing population. The Census Bureau updates the list of ZCTA’s every 10 years.

This mapping table allows looking up the current ZCTA for a ZIP code even if that ZIP code was retired and is no longer in the ZCTA table.

Constant Summary

Constants inherited from BaseRecord

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

Instance Attribute Summary

Attributes inherited from BaseRecord

#status, #updated_at

Class Method Summary collapse

Methods inherited from BaseRecord

#imported?, #manual?, #removed?

Class Method Details

.load!(uri = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/us_geo/zcta_mapping.rb', line 22

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

  import! do
    load_data_file(location) do |row|
      load_record!(zipcode: row["ZIP Code"]) do |record|
        record.zcta_zipcode = row["Active ZCTA5"]
      end
    end
  end
end