Last active
May 7, 2017 02:54
-
-
Save hanbyul-here/7dc7d16a910f264c09bfcfe34a8ef7a2 to your computer and use it in GitHub Desktop.
This file contains 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' | |
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