Skip to content

Instantly share code, notes, and snippets.

@atdrago
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save atdrago/b327abbec32a27525fce to your computer and use it in GitHub Desktop.

Select an option

Save atdrago/b327abbec32a27525fce to your computer and use it in GitHub Desktop.
var turf = require('turf');
turf.load('3m-buffered-point.geojson', function (err, data) {
var features = data.features,
point = features[0],
poly = turf.buffer(point, 3, 'miles'),
polyCoords;
polyCoords = poly.features[0].geometry.coordinates[0];
for (var i = 0, len = polyCoords.length; i < len; i++) {
var coords = polyCoords[i],
vertexPoint = turf.point(coords[0], coords[1]),
distance = turf.distance(point, vertexPoint, 'miles');
console.log(distance)
}
})
/* Output:
3.0029561767624524
2.9769050459117814
2.9014525901415698
2.78473931203686
2.640472647335498
2.487881005444849
2.350793943903439
2.2545636090512726
2.21978422493748
2.2545636090512726
2.350793943903439
2.487881005444849
2.640472647335498
2.78473931203686
2.9014525901415698
2.9769050459117814
3.0029561767624524
2.9768965537986483
2.901386827178415
2.784529649109837
2.6400167324747987
2.487094229412039
2.349651565716341
2.253138429788066
2.2182499180461144
2.253138429788066
2.349651565716341
2.487094229412039
2.6400167324747987
2.784529649109837
2.901386827178415
2.9768965537996195
3.0029561767624524
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment