Class: USGeo::ZctaPlace

Inherits:
BaseRecord
  • Object
show all
Includes:
Demographics
Defined in:
lib/us_geo/zcta_place.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

Class Method Summary collapse

Instance 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



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

def load!(uri = nil)
  location = data_uri(uri || "zcta_places.csv")
  
  import! do
    load_data_file(location) do |row|
      load_record!(zipcode: row["ZCTA5"], place_geoid: row["Place GEOID"]) do |record|
        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"])
      end
    end
  end
end

Instance Method Details

#percent_place_land_areaObject

Percentage of the place land area.



58
59
60
# File 'lib/us_geo/zcta_place.rb', line 58

def percent_place_land_area
  land_area / place.land_area
end

#percent_place_populationObject

Percentage of the place population.



53
54
55
# File 'lib/us_geo/zcta_place.rb', line 53

def percent_place_population
  population.to_f / place.population.to_f
end

#percent_place_total_areaObject

Percentage of the place total area..



63
64
65
# File 'lib/us_geo/zcta_place.rb', line 63

def percent_place_total_area
  total_area / place.total_area
end

#percent_zcta_land_areaObject

Percentage of the ZCTA land area.



43
44
45
# File 'lib/us_geo/zcta_place.rb', line 43

def percent_zcta_land_area
  land_area / zcta.land_area
end

#percent_zcta_populationObject

Percentage of the ZCTA population.



38
39
40
# File 'lib/us_geo/zcta_place.rb', line 38

def percent_zcta_population
  population.to_f / zcta.population.to_f
end

#percent_zcta_total_areaObject

Percentage of the ZCTA total area.



48
49
50
# File 'lib/us_geo/zcta_place.rb', line 48

def percent_zcta_total_area
  total_area / zcta.total_area
end