/node-geoutil

Geographic formulas and geospatial transformations for Node.JS applications

Primary LanguageCoffeeScriptMIT LicenseMIT

Geoutil for Node.JS Build Status

NPM

Install

npm install geoutil --save

Usage

pointDistance()

Get the distance in meters between two points. Technical details.

var pointA = [ 60.39826, 5.32907 ];
var pointB = [ 60.62869, 6.41474 ];

geoutil.pointDistance(pointA, pointB);
// 64781.55866944858

lineDistance()

Get total distance in meters for polyline. Technical details.

var line = [
  [ 61.498792, 8.636448 ],
  [ 61.500270, 8.652638 ],
  [ 61.499957, 8.660266 ],
  [ 61.501822, 8.672846 ],
  [ 61.503748, 8.696228 ]
];

geoutil.lineDistance(line);
// 532.126784613296

polygonArea()

Get total area in meters^2 for polygon. Technical details.

var polygon = [[
  [ 61.498792, 8.636448 ]
  [ 61.500270, 8.652638 ]
  [ 61.499957, 8.660266 ]
  [ 61.501822, 8.672846 ]
  [ 61.503748, 8.696228 ]
  [ 61.498792, 8.636448 ]
]];

geoutil.polygonArea(poly);
// 40.43198051882604

How about GeoJSON?

If you are computing distances on GeoJSON data be sure to set the inverse option (last parameter on lineDistance() and pointDistance()) to true.