Skip to content

Instantly share code, notes, and snippets.

@veltman
Created December 22, 2014 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save veltman/3067f1e1431789c0cf3f to your computer and use it in GitHub Desktop.
Save veltman/3067f1e1431789c0cf3f to your computer and use it in GitHub Desktop.
var fs = require("fs"),
csv = require("csv-parser"),
stringify = require("csv-stringify"),
proj4 = require("proj4");
var nypdProj = 'PROJCS["NAD_1983_StatePlane_New_York_Long_Island_FIPS_3104_Feet",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",984250.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-74.0],PARAMETER["Standard_Parallel_1",40.66666666666666],PARAMETER["Standard_Parallel_2",41.03333333333333],PARAMETER["Latitude_Of_Origin",40.16666666666666],UNIT["Foot_US",0.3048006096012192]]';
var stateplane = proj4(nypdProj);
fs.createReadStream("2013.csv")
.pipe(csv())
.on('data', function(row) {
var wgs84 = stateplane.inverse([row.xcoord,row.ycoord]);
row.lng = wgs84[0];
row.lat = wgs84[1];
return row;
})
.pipe(stringify())
.pipe(fs.createWriteStream("2013-with-latlng.csv"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment