Created
November 8, 2017 22:43
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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