Skip to content

Instantly share code, notes, and snippets.

@saracarl
Created December 10, 2020 18:26
Show Gist options
  • Save saracarl/84079d448c475595ab4bbd6e8b7994ff to your computer and use it in GitHub Desktop.
Save saracarl/84079d448c475595ab4bbd6e8b7994ff to your computer and use it in GitHub Desktop.
Convert a csv of Google Map coordinates (EPSG:900913 Google Maps Global Mercator) to Lat/Long (EPSG:4326 WGS 84)
// build a command line node program following https://developer.okta.com/blog/2019/06/18/command-line-app-with-nodejs
// npm install proj4
// npm install read-excel-file
// expect the input file to be columns: name, X, Y
// run & output to a useful CSV: node . > output.csv
#!/usr/bin/env node
const readXlsxFile = require('read-excel-file/node');
const proj4 = require("proj4");
// File path.
readXlsxFile('./spatial_regions.xlsx').then((rows) => {
// `rows` is an array of rows
// each row being an array of cells.
for (let line of rows) {
console.log(line[0] + "," + proj4("GOOGLE", "EPSG:4326", [line[1],line[2]]))
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment