Skip to content

Instantly share code, notes, and snippets.

@NickCis
Last active May 15, 2021 22:17
Show Gist options
  • Save NickCis/2802cd90305c375f71b2f473a6a64063 to your computer and use it in GitHub Desktop.
Save NickCis/2802cd90305c375f71b2f473a6a64063 to your computer and use it in GitHub Desktop.
// Descargar: https://github.com/alvarezgarcia/provincias-argentinas-geojson
const fetch = require('node-fetch');
const fs = require('fs').promises;
async function main() {
const geojson = {
type: 'FeatureCollection',
features: [],
};
const files = await fs.readdir('.');
for (const file of files) {
if (!file.endsWith('.json') || file.endsWith('output.json') || file.endsWith('package.json')) continue;
const data = require(`./${file}`);
const province = data && data.features && data.features[0];
if (!province) continue;
// https://datosgobar.github.io/georef-ar-api/
const response = await fetch(`https://apis.datos.gob.ar/georef/api/provincias?nombre=${encodeURIComponent(province.properties.name)}`);
const json = await response.json();
province.properties = json.provincias[0];
geojson.features.push(province);
}
await fs.writeFile('./output.json', JSON.stringify(geojson));
}
main();
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment