Skip to content

Instantly share code, notes, and snippets.

@cjdd3b
Created July 19, 2018 16:44
Show Gist options
  • Save cjdd3b/f31e93c06827be09e0467198fb6c47c3 to your computer and use it in GitHub Desktop.
Save cjdd3b/f31e93c06827be09e0467198fb6c47c3 to your computer and use it in GitHub Desktop.
Make a Minnesota precinct map with 2014 turnout data
wget ftp://ftp.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_sos/bdry_votingdistricts/shp_bdry_votingdistricts.zip && \
unzip shp_bdry_votingdistricts.zip && \
shp2json bdry_votingdistricts.shp | \
ndjson-join --left 'd.properties.COUNTYCODE + d.properties.PCTCODE' 'd.county_id + d.precinct_num' <(ndjson-split 'd.features') <(csv2json -n precincts_2014.txt -r ";") | \
ndjson-map 'Object.assign(d[0].properties, d[1]), d[0]' | \
ndjson-reduce 'p.features.push(d), p' '{type: "FeatureCollection", features: []}' | \
geoproject 'd3.geoIdentity().reflectY(true).fitSize([960, 960], d)' | \
geo2topo precincts=- | \
toposimplify -f -p 0.05 | \
topoquantize 1e5 > ./mn-precincts-albers-d3.json && \
rm bdry_votingdistricts.* &&
rm -rf ./metadata &&
rm shp_bdry_votingdistricts.zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment