Skip to content

Instantly share code, notes, and snippets.

View awoodruff's full-sized avatar

Andy Woodruff awoodruff

View GitHub Profile
@awoodruff
awoodruff / README.md
Created April 14, 2014 19:56
topojson.presimplify

Testing the topojson.presimplify function that is used in Dynamic Simplification examples. It's included in this stripped-down example just for testing purposes: seems to work like a charm in most browsers but for a topojson file with much detail (like the county map here), Firefox chokes on topojson.presimplify.

@awoodruff
awoodruff / README.md
Created April 14, 2014 20:27
topojson.presimplify

Testing the topojson.presimplify function that is used in Dynamic Simplification examples. It's included in this stripped-down example just for testing purposes: seems to work like a charm in most browsers but for a topojson file with much detail (like the county map here), Firefox chokes on topojson.presimplify.

@awoodruff
awoodruff / counties.json
Created April 15, 2014 17:19
topojson 1.6.8 presimplify
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@awoodruff
awoodruff / README.md
Created April 15, 2014 17:29
D3 map tiles + dynamic simplification
@awoodruff
awoodruff / index.html
Last active August 29, 2015 14:06
Leaflet map with popups
<html>
<head>
<title>A Leaflet map!</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<style>
#map{ height: 100% }
</style>
</head>
@awoodruff
awoodruff / grid.js
Created January 15, 2015 21:00
Square grid (Mercator) for Turfjs
// creates GeoJSON features (using Turfjs) for square grid cells in the Mercator projection
function grid(minX,minY,maxX,maxY,size){ // arguments are in projected mercator units; conversion functions below
var x = minX,
y = minY,
cells = [],
x0,
y0,
x1,
y1;
@awoodruff
awoodruff / README.md
Last active August 29, 2015 14:19
Rat projections!
@awoodruff
awoodruff / README.md
Last active September 14, 2015 18:01

Have:

A ton of overlapping polygons, representing neighborhoods that people drew and named. (GeoJSON here.) Well-known neighborhoods will have many polygons with the same name, and similar shapes.

Want:

A summary map of polygons representing the area where each neighborhood name is dominant. That is, the area where a given neighborhood name is used more than any other neighborhood name.

My approach:

@awoodruff
awoodruff / circle_thingy.js
Created October 23, 2015 21:26
circular dot symbol thing
var g = symbols.append("g"),
statePath = d3.select( /* selector for the state polygon */ ),
centroid = path.centroid( statePath.datum() );
var total = // whatever the total number of dots is
dotDiameter = 4,
dist = 0,
circumference = 0,
canFit = 1,
count = 0,