Skip to content

Instantly share code, notes, and snippets.

View longhotsummer's full-sized avatar

Greg Kempe longhotsummer

View GitHub Profile
@longhotsummer
longhotsummer / centroid.js
Last active July 7, 2016 06:56
Using D3, topojson and node.js to calculate the centroid of topojson features
/* A node.js script that uses D3 and topojson to calculate and output the lat/long
* coordinates of the centroid for a collection of topojson boundary features.
*/
// install using npm install d3
var d3 = require("d3");
// download from http://d3js.org/topojson.v1.min.js
var topojson = require("./topojson.v1.min.js");
// load json