Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanbyul-here/7dc7d16a910f264c09bfcfe34a8ef7a2 to your computer and use it in GitHub Desktop.
Save hanbyul-here/7dc7d16a910f264c09bfcfe34a8ef7a2 to your computer and use it in GitHub Desktop.
'use strict'
var fs = require('fs');
var jsonfile = require('jsonfile');
fs.readFile(__dirname + '/data/seoul-beobjeongdong.geojson', function(err, data) {
const dongs = JSON.parse(data);
fs.readFile(__dirname + '/data/buildings.json', function(err2, data2) {
const numbers = JSON.parse(data2);
const newFeatures = [];
for(const n in numbers) {
for(const feature of dongs.features) {
if (feature.properties.EMD_KOR_NM == numbers[n].kr_name) {
var trimmedDongCode = n.substring(0, n.length-2);
if(feature.properties.EMD_CD == trimmedDongCode) {
const newFeature = {}
newFeature.properties = {};
newFeature.type ='Feature';
newFeature.properties.en_name = feature.properties.EMD_ENG_NM;
newFeature.properties.kr_name = feature.properties.EMD_KOR_NM;
newFeature.geometry = feature.geometry;
newFeature.properties.average = numbers[n].ave;
newFeature.properties.numberWData = numbers[n].total;
newFeature.properties.numberWOdata = numbers[n].woData;
newFeatures.push(newFeature);
break;
} else {
console.log(feature.properties.EMD_KOR_NM)
console.log('what!');
}
}
}
}
const newGeojson = {
type:"FeatureCollection",
features: newFeatures
};
writeFile(newGeojson);
});
});
function writeFile(obj) {
console.log('write file');
jsonfile.writeFileSync(__dirname + '/data/test5.geojson', obj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment