Skip to content

Instantly share code, notes, and snippets.

@aaronpdennis
aaronpdennis / cb_2014_500k.json
Last active September 9, 2018 11:53
Congressional Districts Map with TopoJSON and Mapbox GL JS
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

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

  1. Find ESRI FeatureServer or MapServer
if (data[0] >= 1) {
context.fillStyle = '#45bae8';
}
@aaronpdennis
aaronpdennis / write-canvas-to-png.js
Created October 12, 2017 15:04
Writing node-canvas to png
canvas
.pngStream()
.pipe(fs.createWriteStream('map_' + name + '.png'));
@aaronpdennis
aaronpdennis / auto-map-projection.js
Created October 4, 2017 17:07
Automatically define an Albers D3.js projection for a GeoJSON feature.
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
aaronpdennis / hdm.json
Last active September 2, 2017 02:45
Process for inputing OpenStreetMap .pbf files, generating vector tiles based off a humanitarian data model, and then hosting those tiles as a data source on Mapbox.
{
"water_source": {
"class": {
"water well": ["man_made=water_well"],
"water tower": ["man_made=water_tower"],
"water tank": ["man_made=storage_tank", "man_made=water_tank"],
"spring": ["natural=spring"],
"drinking water": ["amenity=drinking_water"]
},
"potable": {
@aaronpdennis
aaronpdennis / .block
Last active April 3, 2017 01:48 — forked from mbostock/.block
Project to Bounding Box
license: gpl-3.0
@aaronpdennis
aaronpdennis / PostGIS_cheatsheet.md
Last active March 27, 2017 22:12
useful notes, commands, queries for PostGIS
@aaronpdennis
aaronpdennis / convert.sh
Last active February 24, 2017 03:08
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
directory=${i%*.zip}
mkdir "$directory"
cd "$directory"
filename=${directory##*/}
unzip "../${filename}.zip"
@aaronpdennis
aaronpdennis / general_election_2016_votes.geojson
Created January 24, 2017 23:49
Votes by precinct for each Centre County 2016 general election candidate
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.