Last active
March 21, 2018 20:24
-
-
Save wboykinm/c9a091b72e8cf24b46881c8154837221 to your computer and use it in GitHub Desktop.
A variation on Mike Bostock's us-atlas (https://github.com/topojson/us-atlas) that includes quantized metro areas as a separate object
This file contains 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
#!/bin/bash | |
# mad requirements: | |
npm install topojson-client topojson-server topojson-simplify shapefile ndjson-cli d3-geo-projection mapshaper -g | |
rm -rvf us | |
mkdir -p build us | |
# get both metros and counties | |
if [ ! -f build/cb_2015_us_cbsa_5m.shp ]; then | |
curl -o build/cb_2015_us_cbsa_5m.zip 'https://www2.census.gov/geo/tiger/GENZ2015/shp/cb_2015_us_cbsa_5m.zip' | |
unzip -od build build/cb_2015_us_cbsa_5m.zip cb_2015_us_cbsa_5m.shp cb_2015_us_cbsa_5m.dbf | |
chmod a-x build/cb_2015_us_cbsa_5m.* | |
fi | |
if [ ! -f build/cb_2015_us_county_5m.shp ]; then | |
curl -o build/cb_2015_us_county_5m.zip 'https://www2.census.gov/geo/tiger/GENZ2015/shp/cb_2015_us_county_5m.zip' | |
unzip -od build build/cb_2015_us_county_5m.zip cb_2015_us_county_5m.shp cb_2015_us_county_5m.dbf | |
chmod a-x build/cb_2015_us_county_5m.* | |
fi | |
# awkwardly build them all | |
geo2topo -q 1e5 -n counties=<( \ | |
shp2json -n build/cb_2015_us_county_5m.shp \ | |
| ndjson-filter '!/000$/.test(d.properties.GEOID)' \ | |
| ndjson-map '(d.id = d.properties.GEOID, delete d.properties, d)' \ | |
| geoproject -n 'd3.geoAlbersUsa().scale(1280).translate([480, 300])') \ | |
| toposimplify -f -p 0.25 \ | |
| topomerge states=counties -k 'd.id.slice(0, 2)' \ | |
| topomerge nation=states \ | |
> us/10m.json | |
geo2topo -q 1e5 -n metros=<( \ | |
shp2json -n build/cb_2015_us_cbsa_5m.shp \ | |
| ndjson-filter '!/000$/.test(d.properties.GEOID)' \ | |
| ndjson-map '(d.id = d.properties.GEOID, delete d.properties, d)' \ | |
| geoproject -n 'd3.geoAlbersUsa().scale(1280).translate([480, 300])') \ | |
| toposimplify -f -p 0.25 \ | |
> us/10m-metros.json | |
mapshaper -i combine-files us/10m.json us/10m-metros.json -o us/10m-all.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment