Skip to content

Instantly share code, notes, and snippets.

@wmucheru
Last active January 23, 2018 10:13
Show Gist options
  • Save wmucheru/982da1e777dcb7d030c4692e8aa3ca2c to your computer and use it in GitHub Desktop.
Save wmucheru/982da1e777dcb7d030c4692e8aa3ca2c to your computer and use it in GitHub Desktop.
Pick the property values from an existing GeoJSON, output as json string
let features = sourceJSON.features,
newFeatures = [];
features.map((feature, index) => {
let properties = feature.properties,
ft = {
geometry: feature.geometry,
properties: {
continent: properties.continent,
iso_code: properties.iso_a2,
name: properties.name
},
type: feature.type
};
newFeatures.push(ft);
return;
})
let geojson = { type: "FeatureCollection", features: newFeatures };
console.log(JSON.stringify(geojson));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment