Skip to content

Instantly share code, notes, and snippets.

@dalekunce
Created November 8, 2017 22:43
Show Gist options
  • Save dalekunce/d8562d791709274411f998c5b488e885 to your computer and use it in GitHub Desktop.
Save dalekunce/d8562d791709274411f998c5b488e885 to your computer and use it in GitHub Desktop.
Simple script to get bbox from a geojson and save to a file
'use strict';
const turf = require('turf');
const countries = require('./countries.json');
const jsonfile = require('jsonfile')
var file = 'countries_bbox.json';
var bboxs = [];
for (var i=0; i<countries.features.length; i++) {
var s = countries.features[i];
var country = {
iso: s.properties.ADM0_A3,
name: s.properties.name,
bbox: turf.bbox(s.geometry)
};
bboxs.push(country);
}
// console.log(bboxs);
jsonfile.writeFile(file, bboxs, function (err) {
console.error(err)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment