turf-distance travis-ci npm

Calculates the distance between two point features in degrees, radians, miles, or kilometers.

3 years after

turf-distance

build status

turf distance module

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

Calculates the distance between two Point|points in degrees, 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

Related Repositories

cheap-ruler

cheap-ruler

Fast approximations for common geographic measurements ...

galton

galton

Lightweight Node.js isochrone map server ...

mapbox-java

mapbox-java

Mapbox Java and Android Services. ...

school-finder

school-finder

Geolocation-based web app for locating schools and school districts near you ...

turf-buffer

turf-buffer

Buffers a point, linestring, or polygon Feature/FeatureCollection to a given rad ...


Top Contributors

morganherlocker tmcw lyzidiamond tcql JasonSanford jfrankl mourner djdmbrwsk

Releases

-   v1.1.0 zip tar
-   v1.0.1 zip tar