Skip to content

Instantly share code, notes, and snippets.

@gavinr
Last active July 2, 2018 16:24
Show Gist options
  • Save gavinr/52bf00ba8ef634d96c036df90749dd95 to your computer and use it in GitHub Desktop.
Save gavinr/52bf00ba8ef634d96c036df90749dd95 to your computer and use it in GitHub Desktop.
Script to covert a file of GeoJSON to Esri JSON in NodeJS utilizing the `arcgis-to-geojson-utils` package.
const esriUtils = require('@esri/arcgis-to-geojson-utils');
const fs = require('fs');
const inGeoJson = JSON.parse(fs.readFileSync('FILENAME.json', 'utf8'));
console.log('inGeoJson', inGeoJson);
const result = esriUtils.geojsonToArcGIS(inGeoJson);
let outFeatureSet = {
"displayFieldName": "",
"fieldAliases": {},
"geometryType": "esriGeometryPolygon",
"fields": [],
"spatialReference": { "wkid": 4326 },
"features": result
};
// console.log('result', JSON.stringify(outFeatureSet));
fs.writeFile('out.json', JSON.stringify(outFeatureSet), 'utf8', function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment