This file contains hidden or 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
node buildLegend.js -w ${WIDTH} -h ${HEIGHT} # Build and output legend.svg, minus first line so it can be merged with topo.svg | |
tail -n +1 < legend.svg >> topo.svg | |
# clean up dir | |
find . -name "*.zip" -exec rm -f {} \; | |
rm states.geojson metroareas.geojson circles.geojson topo.geojson legend.svg |
This file contains hidden or 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
#! /usr/bin/env node | |
const fs = require('fs'); | |
const D3Node = require('d3-node'); | |
const parseCSV = require('csv-parse/lib/sync'); | |
// Create a new D3Node instance and then save the path to the d3 library for standalone use. | |
const d3n = new D3Node(); | |
const d3 = d3n.d3; | |
// Load in our CSV file, we'll use this to set our radius domain again. |
This file contains hidden or 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
geoproject "${PROJECTION}.fitSize([${WIDTH}, ${HEIGHT}], d)" < topo.geojson | # Scale the geojson to needed specs | |
ndjson-split 'd.features' | # convert to ndjson | |
geo2svg --newline-delimited -w ${WIDTH} -h ${HEIGHT} | # convert ndjson to svg | |
sed '$d' > topo.svg # remove last line for splice with legend and output |
This file contains hidden or 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
#! /usr/bin/env node | |
const fs = require('fs'); | |
// Import the state geodata and the metro area circles geodata | |
const states = JSON.parse(fs.readFileSync('./states.geojson', 'utf8')); | |
const circles = JSON.parse(fs.readFileSync('./circles.geojson', 'utf8')); | |
// Filter and map the state features to include as little data as possible | |
const parseStates = features => features.map(({ type, properties, geometry }) => ({ | |
type, |
This file contains hidden or 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
#! /usr/bin/env node | |
const fs = require('fs'); | |
const turf = require('@turf/turf'); | |
const parseCSV = require('csv-parse/lib/sync'); | |
const d3 = require('d3'); | |
// Import the metro areas geodata as an object and the percent of undocumented residents data as an array of obj. | |
const metro = JSON.parse(fs.readFileSync('./metroareas.geojson', 'utf8')); | |
const undocumented = parseCSV(fs.readFileSync('./metro-area-percent-undocumented.csv', 'utf8'), { columns: true }); |
This file contains hidden or 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
shp2json cb_2017_us_state_20m.shp > states.geojson # Convert state shapefile to geojson | |
shp2json cb_${YEAR}_us_cbsa_20m.shp > metroareas.geojson # Convert metro area shapefile to geojson |
This file contains hidden or 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 | |
# Year to pull census geo data from | |
YEAR=2017 | |
# Conditionally download the Pew data | |
if [ ! -f metro-area-percent-undocumented.csv ]; then | |
curl -Lo metro-area-percent-undocumented.csv \ | |
"https://query.data.world/s/awyahzfiikyoqi5ygpvauqslwmqltr" | |
fi |
This file contains hidden or 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
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible). | |
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export. | |
var FORMAT_ONELINE = 'One-line'; | |
var FORMAT_MULTILINE = 'Multi-line'; | |
var FORMAT_PRETTY = 'Pretty'; | |
var LANGUAGE_JS = 'JavaScript'; | |
var LANGUAGE_PYTHON = 'Python'; |
This file contains hidden or 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
^(?!Warning:).*$ |
This file contains hidden or 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
/** | |
* used to populate the source List... (so we can add sources to reports) | |
*/ | |
$scope.filterSources = { | |
filterVal: '', | |
privatePublic: 'all', | |
resetPagination: false, |
NewerOlder