I'm working on a script where I'm converting a text file "data" to an array of objects and will subsequently join that array to Geojson via a common key "GEOID". In "data" I have two objects STATE_FIP and COUNTY_FIP. Those two combined will create a common key to match "GEOID". I need to concatenate them programmatically. Is there a way to do this easily? Below is a screen shot of "data" Thank you!
Not much info given but...try this:
var additionalProps = {}
data.forEach(obj => {
geoid = obj.STATE_FIP + obj.COUNTY_FIP
additionalProps[geoid] = obj
})
var updatedGeoJson = {
"type": "FeatureCollection",
"features": []
};
oldGeoJson.features.forEach(x => {
geoid = x.properties.GEOID
newProps = {...x.properties, ...additionalProps[geoid]}
x.properties = newProps
updatedGeoJson.features.push(x)
})