Visualizing taxpayer migration data from the IRS
The IRS publishes data on migration patterns within the US based on changes in taxpayers’ return addresses. This is a project centered on visualizing and exploring that data.
Initially just centering on San Francisco, I'm now working on turning the data-munging steps into an Express-based api to allow for exploration of any county in the US.
This means there are essentially two projects within this one:
- a backend api for delivering data
- a frontend visualization for consuming that data
https://www.irs.gov/statistics/soi-tax-stats-migration-data
https://www.irs.gov/statistics/soi-tax-stats-migration-data-2014-2015
https://www.census.gov/topics/population/migration/guidance/county-to-county-migration-flows.html https://www.census.gov/topics/population/migration/data/tables.html
census data
Install missing command line dependencies by following directions on website and something like:
- downloading directly
brew install {pkg}npm install --global {pkg}yarn global add {pkg}
- clone this repo
npm installnpm run get-datanpm run atlasnpm run munge
- get the data ^^
irs-migration/munge/pg$ ./parse-county-pg.shirs-migration/munge/pg$ node getseeddata.jsirs-migration/api$ yarn install(yes, the backend uses yarn while the frontend uses npm.)- make sure your db is running
irs-migration/api$ ./node_modules/.bin/sequelize db:migrateirs-migration/api$ ./node_modules/.bin/sequelize db:seed:all
irs-migration/api$ yarn run start:dev
Currently, only focuses on San Francisco and consumes a static file created by npm run munge.
- get all the data ^^
- use webpack:
npm run start
- map code is in index.js
Say, Manhattan (FIPS code 36 061):
- get all the data ^^
irs-migration$ ./munge/parse-county.sh 36 061- files are now in
data/36061:- inflow/outflow csvs
- topojson of destination counties
- TODO in
download.shhaving to do with character encoding conversion - change color scale to some sort of threshold scale (automatic)
- connect centroids with lines
- use circles on map instead of coloring counties
- enter/exit morph between circle and county path
- bumps chart of top (10? 20?) counties year-to-year
- barchart of migration by state
- sankey/sunburst/tree? (county-> state-> sf)
- select county to compare over time
- combine gif-munge and gif-create into single node script?
- note: 06075inflowcombined.csv has duplicate rows for cook county IL
- command line generation of map
- see
munge/gif-munge.jsandmunge/gif-create.sh
- see
- separate build dev/dist webpack functionality
- better mouseover tooltip
- zoom map
- line chart of total immigration/emigration year-to-year
- allow user to choose different year
California 06
- 075 San Francisco
- 001 Alameda (Oakland, Berkeley, East Bay)
- 041 Marin
- 081 San Mateo (Silicon Valley)
- 097 Sonoma
- 055 Napa
- 013 Contra Costa
- 085 Santa Clara
- 087 Santa Cruz
- 095 Solano
New York 36
- 005 Bronx
- 047 Kings (Brooklyn)
- 061 New York (Manhattan)
- 081 Queens
- 085 Richmond (Staten Island)
Texas 48
- 201 Harris (Houston)
- 029 Bexar (San Antonio)
- 113 Dallas
- 453 Travis (Austin)
- 457 Tyler
Illinois 17
- 031 Cook (Chicago)
- 019 Champaign
Virginia 51
- 770 Roanoke City
- 161 Roanoke County
- 760 Richmond City
- 159 Richmond County
Washington, DC 11 001
To make gif of migration into New York County, NY (FIPS code 36061):
irs-migration$ ./munge/parse-county.sh 36 061irs-migration$ cd mungemunge$ node gif-munge.js 36 061 inmunge$ ./gif-create.sh 36 061 in
To make legend for gifs
- edit html file
munge/legend.html - change variable
valsto the contents oflegendValsin.json/legendValsin.json - choose desired colorArray
- open
munge/legend.htmlin web browser - screenshot