This PR grabs contextual data for Alaska and the entire US, and adds them to the results for places in Alaska. For the Census data this was relatively straightforward, but for the CDC datasets I actually had to change the code quite a bit to accomplish this. The changes actually simplified the CDC part of the code and made for a more efficient API call, so the processing time is now a few minutes shorter!
I ended up using SoQL queries to grab all variables/locations for each place in one API call. If the place was Alaska or US, I queried for the whole state or the whole country at the tract level and then aggregated the results using the same aggregation math reviewed in the last PR.
And as requested in the last project meeting, I added a variable for percent of population under 5 (field is pct_under_5) which should be incorporated into the NCR data viz when convenient.
TO TEST:
Review the new code in utilities/functions.py, to see how state and US options were implemented.
Run fetch_data_and_export.ipynb and join_results_to_census_polygons.ipynb. The output files created by these notebooks (tbl/data_to_export.csv and shp/demographics.shp) should be identical to the versions committed in this branch.
Optionally, check out some of the new URLs that use SoQL queries for CDC data. (These are printed in the notebook but need to be copy/pasted because the hyperlink ends at the URL whitespace).
This PR grabs contextual data for Alaska and the entire US, and adds them to the results for places in Alaska. For the Census data this was relatively straightforward, but for the CDC datasets I actually had to change the code quite a bit to accomplish this. The changes actually simplified the CDC part of the code and made for a more efficient API call, so the processing time is now a few minutes shorter!
I ended up using SoQL queries to grab all variables/locations for each place in one API call. If the place was Alaska or US, I queried for the whole state or the whole country at the tract level and then aggregated the results using the same aggregation math reviewed in the last PR.
And as requested in the last project meeting, I added a variable for percent of population under 5 (field is
pct_under_5
) which should be incorporated into the NCR data viz when convenient.TO TEST:
utilities/functions.py
, to see how state and US options were implemented.fetch_data_and_export.ipynb
andjoin_results_to_census_polygons.ipynb
. The output files created by these notebooks (tbl/data_to_export.csv
andshp/demographics.shp
) should be identical to the versions committed in this branch.