sfbrigade / datasci-sba

Solving problems with the Small Business Administration
10 stars 18 forks source link

Find Congressional District and County GeoJSON Files #32

Open VincentLa14 opened 7 years ago

VincentLa14 commented 7 years ago

Iterations on Map layers will use congressional districts and county levels. Let's find those GeoJSON files.

thfield commented 7 years ago

to get the topojson file of Zip codes here, i used the makefile (tutorial) attached.
(disclaimer: i might have an older version of cli topojson on my computer, so i would recommend following this tutorial up through creating geoJSON files)

the census might publish a shapefile for congressional district, or you might be able to find one from another source.

if you're looking for topoJSON files of counties or states, check out us-atlas


Makefile:

cb_2016_us_zcta510_500k.zip:
  curl -O 'http://www2.census.gov/geo/tiger/GENZ2016/shp/cb_2016_us_zcta510_500k.zip'

cb_2016_us_zcta510_500k/cb_2016_us_zcta510_500k.shp: cb_2016_us_zcta510_500k.zip
    unzip cb_2016_us_zcta510_500k.zip
    touch cb_2016_us_zcta510_500k.shp

zipcodes.json: cb_2016_us_zcta510_500k/cb_2016_us_zcta510_500k.shp
    topojson -o zipcodes.json -- zipcodes=cb_2016_us_zcta510_500k.shp

us.json:
    curl -Lo us.json 'https://unpkg.com/us-atlas@latest/us/10m.json'

ca.json: us.json
    mapshaper us.json \
  -filter 'FID === "06"' target=states \
  -o ca.json format=topojson target=states

# ca_zips.geojson manually created using QGIS to clip zipcodes.json using the boundaries of ca.json

ca_zips.json: ca_zips.geojson
    mapshaper ca_zips.geojson \
    -simplify 20% \
    -o format=topojson

ca_zips_simple.json: ca_zips.json
    topojson -o ca_zips_simple.json -p GEOID10 -- ca_zips.json