Last active
July 2, 2018 16:24
-
-
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.
This file contains hidden or 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
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