Skip to content

Commit 83ba3f9

Browse files
authored
Merge pull request #1351 from cmu-delphi/census_flag
Add census year flag to geomapper
2 parents 35b3206 + 3cd0bca commit 83ba3f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+332159
-31
lines changed

_delphi_utils_python/data_proc/geomap/geo_data_proc.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@
2020

2121

2222
# Source files
23+
YEAR = 2019
2324
INPUT_DIR = "./old_source_files"
24-
OUTPUT_DIR = "../../delphi_utils/data"
25+
OUTPUT_DIR = f"../../delphi_utils/data/{YEAR}"
2526
FIPS_BY_ZIP_POP_URL = "https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt?#"
2627
ZIP_HSA_HRR_URL = "https://atlasdata.dartmouth.edu/downloads/geography/ZipHsaHrr18.csv.zip"
2728
ZIP_HSA_HRR_FILENAME = "ZipHsaHrr18.csv"
2829
FIPS_MSA_URL = "https://www2.census.gov/programs-surveys/metro-micro/geographies/reference-files/2018/delineation-files/list1_Sep_2018.xls"
2930
JHU_FIPS_URL = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/UID_ISO_FIPS_LookUp_Table.csv"
3031
STATE_CODES_URL = "http://www2.census.gov/geo/docs/reference/state.txt?#"
31-
FIPS_POPULATION_URL = "https://www2.census.gov/programs-surveys/popest/datasets/2010-2020/counties/totals/co-est2020-alldata.csv"
32+
FIPS_POPULATION_URL = f"https://www2.census.gov/programs-surveys/popest/datasets/2010-{YEAR}/counties/totals/co-est{YEAR}-alldata.csv"
3233
FIPS_PUERTO_RICO_POPULATION_URL = "https://www2.census.gov/geo/docs/maps-data/data/rel/zcta_county_rel_10.txt?"
3334
STATE_HHS_FILE = "hhs.txt"
3435

@@ -265,11 +266,11 @@ def create_state_hhs_crosswalk():
265266
def create_fips_population_table():
266267
"""Build a table of populations by FIPS county codes.
267268
268-
Uses US Census Bureau population data from 2020, with 2010 population data for Puerto Rico and a few exceptions.
269+
Uses US Census Bureau population data as determined by the YEAR variable, with 2010 population data for Puerto Rico and a few exceptions.
269270
"""
270271
census_pop = pd.read_csv(FIPS_POPULATION_URL, encoding="ISO-8859-1")
271272
census_pop["fips"] = census_pop.apply(lambda x: f"{x['STATE']:02d}{x['COUNTY']:03d}", axis=1)
272-
census_pop = census_pop.rename(columns={"POPESTIMATE2020": "pop"})[["fips", "pop"]]
273+
census_pop = census_pop.rename(columns={f"POPESTIMATE{YEAR}": "pop"})[["fips", "pop"]]
273274

274275
# Set population for Dukes and Nantucket combo county
275276
dukes_pop = int(census_pop.loc[census_pop["fips"] == "25007", "pop"])

0 commit comments

Comments
 (0)