Skip to content

Instantly share code, notes, and snippets.

View craiggoldstone's full-sized avatar

Craig Goldstone craiggoldstone

  • United Kingdom
View GitHub Profile
@rclark
rclark / lines2polysNoder.js
Created August 6, 2013 21:34
JSTS to create polygons from a network of arbitrary, or "spaghetti" lines. This uses jsts.noding to "clean" or "planarize" the line network, which is crazy fast compared to the "Union" alternative here: https://gist.github.com/rclark/6123614
var jsts = require("jsts"),
u = require("underscore"),
fs = require("fs");
fs.readFile("/Users/ryan/Desktop/hv-lines.geojson", function (err, data) {
var geojson = JSON.parse(data),
writer = new jsts.io.GeoJSONWriter(),
polygonizer = new jsts.operation.polygonize.Polygonizer(),
noder = new jsts.noding.MCIndexNoder(),
intersector = new jsts.algorithm.RobustLineIntersector(),