Class: USGeo::ZctaUrbanArea

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

Overview

Mapping of ZCTA’s to urban areas they overlap with.

Constant Summary

Constants inherited from BaseRecord

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

Instance Attribute Summary

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 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



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/us_geo/zcta_urban_area.rb', line 17

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

  import! do
    load_data_file(location) do |row|
      load_record!(zipcode: row["ZCTA5"], urban_area_geoid: row["Urban Area GEOID"]) do |record|
        record.land_area = row["Land Area"]
        record.water_area = row["Water Area"]
      end
    end
  end
end

Instance Method Details

#percent_urban_area_land_areaObject

Percentage of the urban area land area.



42
43
44
# File 'lib/us_geo/zcta_urban_area.rb', line 42

def percent_urban_area_land_area
  land_area / urban_area.land_area
end

#percent_urban_area_total_areaObject

Percentage of the urban area total area.



47
48
49
# File 'lib/us_geo/zcta_urban_area.rb', line 47

def percent_urban_area_total_area
  total_area / urban_area.total_area
end

#percent_zcta_land_areaObject

Percentage of the ZCTA land area.



32
33
34
# File 'lib/us_geo/zcta_urban_area.rb', line 32

def percent_zcta_land_area
  land_area / zcta.land_area
end

#percent_zcta_total_areaObject

Percentage of the ZCTA total area.



37
38
39
# File 'lib/us_geo/zcta_urban_area.rb', line 37

def percent_zcta_total_area
  total_area / zcta.total_area
end