Class: USGeo::Zcta

Inherits:
BaseRecord
  • Object
show all
Includes:
Demographics
Defined in:
lib/us_geo/zcta.rb

Overview

ZIP code tabulation area. These roughly map to U.S. Postal service ZIP codes, but are designed for geographic and demographic purposes instead of mail routing. In particular certain optimizations that the Postal Service makes to optimize mail routing are omitted or smoothed over (i.e. ZIP codes mapping to a single building, one-off enclaves, etc.)

ZCTA’s can span counties, but the one with the majority of the residents is identified as the primary county for when a single county is required.

ZCTA’s can span urbanized area, but the one with the majority of the residents is identified as the primary urbanized area for when a single area is required.

Constant Summary

Constants inherited from BaseRecord

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

Class Method Summary collapse

Methods included from Demographics

#percent_land, #population_density, #total_area

Methods inherited from BaseRecord

#imported?, #manual?, #removed?

Class Method Details

.load!(uri = nil) ⇒ Object



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

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

  import! do
    load_data_file(location) do |row|
      load_record!(zipcode: row["ZCTA5"]) do |record|
        record.primary_county_geoid = row["Primary County"]
        record.primary_urban_area_geoid = row["Primary Urban Area"]
        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