Last active
October 2, 2020 19:44
-
-
Save samatt/b049e0300813838632fe575eff5705b4 to your computer and use it in GitHub Desktop.
maps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cnf ?= config.env | |
include $(cnf) | |
export $(shell sed 's/=.*//' $(cnf)) | |
.PHONY: help | |
help: ## This help. | |
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | |
.DEFAULT_GOAL := help | |
# [ -d $(DATA_DIR) ] || mkdir -p $(DATA_DIR) ] | |
# SESSION_DIR="$(DATA_DIR)\/$(SESSION)" | |
# DOCKETS_SEARCH_RESULTS="$(SESSION_DIR)/search-results/$(DOCKET_SEARCH_TERM).json" | |
# DOCKETS=$(shell csvcut -d , - c 18,4,1 $(CASES_FILE) | sed -e 1d | awk -F, '{print sprintf("%s-%s-%s.html", $$1, $$2, $$3)}'| sed -e 's/^/${SESSION_DIR}\//g' ) | |
# $(DATA_DIR)/cb_${YEAR}_${STATE}_tract_500k.zip: ## Download the census tract boundaries. | |
# wget -O "$(DATA_DIR)/cb_${YEAR}_${STATE}_tract_500k.zip" \ | |
# "http://www2.census.gov/geo/tiger/GENZ${YEAR}/shp/cb_${YEAR}_${STATE}_tract_500k.zip" | |
${DATA_DIR}/census_tract.zip:## Download the latimes boundaries. | |
wget -O "${DATA_DIR}/census_tract.zip" \ | |
"http://boundaries.latimes.com/1.0/boundary-set/census-tracts-2012/?format=shp" | |
${DATA_DIR}/cb_${YEAR}_${STATE}_${COUNTY}_tract_B01003.json:## Download the latimes boundaries. | |
wget -O ${DATA_DIR}/cb_${YEAR}_${STATE}_${COUNTY}_tract_B01003.json \ | |
"https://api.census.gov/data/${YEAR}/acs/acs5?get=B01003_001E&for=tract:*&in=state:${STATE}&in=county:${COUNTY}&key=${KEY}" | |
${DATA_DIR}/census_tract.shp: ${DATA_DIR}/census_tract.zip | |
unzip ${DATA_DIR}/census_tract.zip | |
mv census\ tract\ \(2012\).shp ${DATA_DIR}/census_tract.shp | |
mv census\ tract\ \(2012\).prj ${DATA_DIR}/census_tract.prj | |
mv census\ tract\ \(2012\).shx ${DATA_DIR}/census_tract.shx | |
mv census\ tract\ \(2012\).dbf ${DATA_DIR}/census_tract.dbf | |
${DATA_DIR}/census_tract_geo.ndjson: | |
shp2json ${DATA_DIR}/census_tract.shp \ | |
| geoproject "d3.geoConicConformal().parallels([34 + 2 / 60, 35 + 28 / 60]).rotate([118, 0]).fitExtent([[10, 10], [${WIDTH} - 10, ${HEIGHT} - 10]], d)" \ | |
| ndjson-split 'd.features' \ | |
| ndjson-map 'd.id = d.properties.GEOID.slice(2), d' > ${DATA_DIR}/census_tract_geo.ndjson | |
${DATA_DIR}/census_tract_B01003.ndjson: ${DATA_DIR}/cb_${YEAR}_${STATE}_${COUNTY}_tract_B01003.json | |
ndjson-cat ${DATA_DIR}/cb_${YEAR}_${STATE}_${COUNTY}_tract_B01003.json \ | |
| ndjson-split 'd.slice(1)'\ | |
| ndjson-map '{id: d[2] + d[3], B01003: +d[0]}' > ${DATA_DIR}/census_tract_B01003.ndjson | |
${DATA_DIR}/${YEAR}_${STATE}_${COUNTY}_B01003_geo.ndjson: ${DATA_DIR}/census_tract_geo.ndjson ${DATA_DIR}/census_tract_B01003.ndjson | |
ndjson-join 'd.id' ${DATA_DIR}/census_tract_geo.ndjson ${DATA_DIR}/census_tract_B01003.ndjson | ndjson-map 'd[0].properties = {density: Math.floor(d[1].B01003 / d[0].properties.ALAND * 2589975.2356)}, d[0]' > ${DATA_DIR}/${YEAR}_${STATE}_${COUNTY}_B01003_geo.ndjson | |
${DATA_DIR}/${YEAR}_${STATE}_${COUNTY}_B01003_topo.json: ${DATA_DIR}/${YEAR}_${STATE}_${COUNTY}_B01003_geo.ndjson ## HELP | |
geo2topo -n tracts=${DATA_DIR}/${YEAR}_${STATE}_${COUNTY}_B01003_geo.ndjson \ | |
| toposimplify -p 1 -f \ | |
| topomerge -k 'd.id.slice(0, 3)' counties=tracts \ | |
| topomerge --mesh -f 'a !== b' counties=counties \ | |
| topoquantize 1e5 \ | |
> ${DATA_DIR}/${YEAR}_${STATE}_${COUNTY}_B01003_topo.json | |
lat_tract_B01003: ${DATA_DIR}/${YEAR}_${STATE}_${COUNTY}_B01003_topo.json | |
echo "Topojson file at: ${DATA_DIR}/${YEAR}_${STATE}_${COUNTY}_B01003_topo.json" | |
# | |
${DATA_DIR}/zcta.zip:## Download the latimes boundaries. | |
wget -O "${DATA_DIR}/census_tract.zip" \ | |
http://boundaries.latimes.com/1.0/boundary-set/zip-code-tabulation-areas-2012/?format=shp | |
${DATA_DIR}/zcta.shp: ${DATA_DIR}/zcta.zip | |
unzip ${DATA_DIR}/census_tract.zip | |
mv zip\ code\ tabulation\ area\ \(2012\).shp ${DATA_DIR}/zcta.shp | |
mv zip\ code\ tabulation\ area\ \(2012\).prj ${DATA_DIR}/zcta.prj | |
mv zip\ code\ tabulation\ area\ \(2012\).shx ${DATA_DIR}/zcta.shx | |
mv zip\ code\ tabulation\ area\ \(2012\).dbf ${DATA_DIR}/zcta.dbf | |
${DATA_DIR}/zcta_geo.ndjson: ${DATA_DIR}/zcta.shp | |
shp2json ${DATA_DIR}/zcta.shp \ | |
| geoproject "d3.geoConicConformal().parallels([34 + 2 / 60, 35 + 28 / 60]).rotate([118, 0]).fitExtent([[10, 10], [${WIDTH} - 10, ${HEIGHT} - 10]], d)" \ | |
| ndjson-split 'd.features' \ | |
| ndjson-map 'd.geoid = +d.properties.ZCTA5CE10, d' > ${DATA_DIR}/zcta_geo.ndjson | |
# zcta | |
${DATA_DIR}/zcta_race.ndjson: preprocessed/acs5_2018_race_zcta.json | |
ndjson-cat preprocessed/acs5_2018_race_zcta.json \ | |
| ndjson-split > ${DATA_DIR}/zcta_race.ndjson | |
${DATA_DIR}/zcta_race_geo.ndjson: ${DATA_DIR}/zcta_geo.ndjson ${DATA_DIR}/zcta_race.ndjson | |
ndjson-join 'd.geoid' ${DATA_DIR}/zcta_geo.ndjson ${DATA_DIR}/zcta_race.ndjson | ndjson-map 'd[0].properties = d[1], d[0]' > ${DATA_DIR}/zcta_race_geo.ndjson | |
${DATA_DIR}/zcta_race_topo.json: ${DATA_DIR}/zcta_race_geo.ndjson ## HELP | |
geo2topo -n tracts=${DATA_DIR}/zcta_race_geo.ndjson \ | |
| toposimplify -p 1 -f \ | |
| topoquantize 1e5 \ | |
> ${DATA_DIR}/zcta_race_topo.json | |
lat_zcta: ${DATA_DIR}/zcta_race_topo.json | |
# counties.zip: | |
# curl -o counties.zip 'http://www2.census.gov/geo/tiger/GENZ2010/gz_2010_us_050_00_20m.zip' | |
# gz_2010_us_050_00_20m.shp: counties.zip | |
# unzip counties.zip | |
# touch gz_2010_us_050_00_20m.shp | |
# counties.json: gz_2010_us_050_00_20m.shp | |
# topojson -o counties.json -- counties=gz_2010_us_050_00_20m.shp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment