turf-distance
turf distance module
Last updated 8 years ago by tmcw .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install turf-distance 
SYNC missed versions from official npm registry.

turf-distance

build status

turf distance module

turf.distance(from, to, [units=kilometers])

Calculates the distance between two Point|points in degress, radians, miles, or kilometers. This uses the Haversine formula to account for global curvature.

Parameters

parameter type description
from Feature.<Point> origin point
to Feature.<Point> destination point
[units=kilometers] String optional: can be degrees, radians, miles, or kilometers

Example

var point1 = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Point",
    "coordinates": [-75.343, 39.984]
  }
};
var point2 = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Point",
    "coordinates": [-75.534, 39.123]
  }
};
var units = "miles";

var points = {
  "type": "FeatureCollection",
  "features": [point1, point2]
};

//=points

var distance = turf.distance(point1, point2, units);

//=distance

Returns Number, distance between the two points

Installation

Requires nodejs.

$ npm install turf-distance

Tests

$ npm test

Current Tags

  • 3.0.7-canary.ae89c8b3                                ...           canary (8 years ago)
  • 3.0.12                                ...           latest (8 years ago)

16 Versions

  • 3.0.12 [deprecated]           ...           8 years ago
  • 3.0.10 [deprecated]           ...           8 years ago
  • 3.0.7-canary.ae89c8b3                                ...           8 years ago
  • 3.0.5 [deprecated]           ...           8 years ago
  • 3.0.1 [deprecated]           ...           8 years ago
  • 3.0.0-canary.7879bf6c                                ...           8 years ago
  • 3.0.0-canary.2f5f7167                                ...           8 years ago
  • 1.1.0 [deprecated]           ...           9 years ago
  • 1.0.1 [deprecated]           ...           10 years ago
  • 1.0.0 [deprecated]           ...           10 years ago
  • 0.1.5 [deprecated]           ...           10 years ago
  • 0.1.4 [deprecated]           ...           10 years ago
  • 0.1.3 [deprecated]           ...           10 years ago
  • 0.1.2 [deprecated]           ...           10 years ago
  • 0.1.1 [deprecated]           ...           11 years ago
  • 0.1.0 [deprecated]           ...           11 years ago
Downloads
Total 15
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE