class USGeo::ZctaPlace

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

Public Class Methods

load!(uri = nil) click to toggle source
# 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

Public Instance Methods

percent_place_land_area() click to toggle source

Percentage of the place land area.

# File lib/us_geo/zcta_place.rb, line 58
def percent_place_land_area
  land_area / place.land_area
end
percent_place_population() click to toggle source

Percentage of the place population.

# File lib/us_geo/zcta_place.rb, line 53
def percent_place_population
  population.to_f / place.population.to_f
end
percent_place_total_area() click to toggle source

Percentage of the place total area..

# File lib/us_geo/zcta_place.rb, line 63
def percent_place_total_area
  total_area / place.total_area
end
percent_zcta_land_area() click to toggle source

Percentage of the ZCTA land area.

# File lib/us_geo/zcta_place.rb, line 43
def percent_zcta_land_area
  land_area / zcta.land_area
end
percent_zcta_population() click to toggle source

Percentage of the ZCTA population.

# File lib/us_geo/zcta_place.rb, line 38
def percent_zcta_population
  population.to_f / zcta.population.to_f
end
percent_zcta_total_area() click to toggle source

Percentage of the ZCTA total area.

# File lib/us_geo/zcta_place.rb, line 48
def percent_zcta_total_area
  total_area / zcta.total_area
end