Skip to content

Instantly share code, notes, and snippets.

@bradoyler
Last active August 16, 2016 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradoyler/329d85abfbf1f462c09b6d2271e7f2fe to your computer and use it in GitHub Desktop.
Save bradoyler/329d85abfbf1f462c09b6d2271e7f2fe to your computer and use it in GitHub Desktop.
Congress Districts by State. makefile and shell script to be used with us-atlas
#### add this to bottom of Makefile in https://github.com/mbostock/us-atlas
####### congress outputs
shp/al/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '01'" $@ $<
shp/ak/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '02'" $@ $<
shp/az/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '04'" $@ $<
shp/ar/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '05'" $@ $<
shp/ca/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '06'" $@ $<
shp/co/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '08'" $@ $<
shp/ct/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '09'" $@ $<
shp/de/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '10'" $@ $<
shp/dc/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '11'" $@ $<
shp/fl/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '12'" $@ $<
shp/ga/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '13'" $@ $<
shp/hi/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '15'" $@ $<
shp/id/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '16'" $@ $<
shp/il/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '17'" $@ $<
shp/in/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '18'" $@ $<
shp/ia/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '19'" $@ $<
shp/ks/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '20'" $@ $<
shp/ky/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '21'" $@ $<
shp/la/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '22'" $@ $<
shp/me/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '23'" $@ $<
shp/md/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '24'" $@ $<
shp/ma/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '25'" $@ $<
shp/mi/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '26'" $@ $<
shp/mn/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '27'" $@ $<
shp/ms/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '28'" $@ $<
shp/mo/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '29'" $@ $<
shp/mt/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '30'" $@ $<
shp/ne/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '31'" $@ $<
shp/nv/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '32'" $@ $<
shp/nh/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '33'" $@ $<
shp/nj/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '34'" $@ $<
shp/nm/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '35'" $@ $<
shp/ny/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '36'" $@ $<
shp/nc/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '37'" $@ $<
shp/nd/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '38'" $@ $<
shp/oh/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '39'" $@ $<
shp/ok/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '40'" $@ $<
shp/or/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '41'" $@ $<
shp/pa/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '42'" $@ $<
shp/ri/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '44'" $@ $<
shp/sc/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '45'" $@ $<
shp/sd/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '46'" $@ $<
shp/tn/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '47'" $@ $<
shp/tx/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '48'" $@ $<
shp/ut/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '49'" $@ $<
shp/vt/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '50'" $@ $<
shp/va/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '51'" $@ $<
shp/wa/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '53'" $@ $<
shp/wv/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '54'" $@ $<
shp/wi/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '55'" $@ $<
shp/wy/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '56'" $@ $<
shp/as/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '60'" $@ $<
shp/fm/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '64'" $@ $<
shp/gu/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '66'" $@ $<
shp/mh/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '68'" $@ $<
shp/mp/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '69'" $@ $<
shp/pw/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '70'" $@ $<
shp/pr/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '72'" $@ $<
shp/um/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '74'" $@ $<
shp/vi/congress-ungrouped.shp: shp/us/congress-ungrouped.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATEFP = '78'" $@ $<
#!/usr/bin/env bash
for state in al ak az ar ca co ct de fl ga hi id il \in ia ks ky la me md ma mi mn ms mo mt \
ne nv nh nj nm ny nc nd oh ok or pa ri sc sd tn tx ut vt va wa wv wi wy
do
make shp/$state/congress-ungrouped.shp
done
for state in al ak az ar ca co ct de fl ga hi id il \in ia ks ky la me md ma mi mn ms mo mt \
ne nv nh nj nm ny nc nd oh ok or pa ri sc sd tn tx ut vt va wa wv wi wy
do
topojson -o topo/districts/$state-congress.json -s 1e-7 -q 5000 shp/$state/congress-ungrouped.shp -p
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment