Skip to content

Instantly share code, notes, and snippets.

View simple-conditional.js
if (data[0] >= 1) {
context.fillStyle = '#45bae8';
aaronpdennis / write-canvas-to-png.js
Created Oct 12, 2017
Writing node-canvas to png
View write-canvas-to-png.js
.pipe(fs.createWriteStream('map_' + name + '.png'));
aaronpdennis / auto-map-projection.js
Created Oct 4, 2017
Automatically define an Albers D3.js projection for a GeoJSON feature.
View auto-map-projection.js
function framedProjection(feature, mapWidth, mapHeight) {
var projection = d3.geoAlbers();
var centroid = d3.geoCentroid(feature);
projection.rotate([-1 * centroid[0]]).scale(1).translate([0, 0]);
var path = d3.geoPath().projection(projection);
var bounds = path.bounds(feature);
aaronpdennis / .block
Last active Apr 3, 2017 — forked from mbostock/.block
Project to Bounding Box
View .block
license: gpl-3.0
aaronpdennis /
Last active Feb 24, 2017
script for converting NAD83 shapefiles in subdirectories to WGS84 GeoJSON
function shp2geojson() {
ogr2ogr -f GeoJSON -s_srs EPSG:4269 -t_srs EPSG:4326 "../../$1.geojson" "$1.shp"
for i in ./*/*.zip; do
mkdir "$directory"
cd "$directory"
unzip "../${filename}.zip"
aaronpdennis / general_election_2016_votes.geojson
Created Jan 24, 2017
Votes by precinct for each Centre County 2016 general election candidate
View general_election_2016_votes.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View state_fips_codes.csv
Name FIPS Abbr
Alabama 01 AL
Alaska 02 AK
Arizona 04 AZ
Arkansas 05 AR
California 06 CA
Colorado 08 CO
Connecticut 09 CT
Delaware 10 DE
District of Columbia 11 DC

Legislative Districts

Section 16.

The Commonwealth shall be divided into fifty senatorial and two hundred three representative districts, which shall be composed of compact and contiguous territory as nearly equal in population as practicable. Each senatorial district shall elect one Senator, and each representative district one Representative. Unless absolutely necessary no county, city, incorporated town, borough, township or ward shall be divided in forming either a senatorial or representative district.


Extract data from ESRI REST endpoint to GeoJSON (on Windows)

  1. Find ESRI FeatureServer or MapServer
until [ $image -gt $number_of_images ]
echo $image
convert $image.png -crop 1008x1003+775+297 $image.cropped.png
a=`expr $a + 1`