nearestPointToLine
Description
Returns the closest point, of a collection of points,
to a line. The returned point has a dist
property indicating its distance to the line.
Parameters
Name | Type | Description |
---|---|---|
points | FeatureCollection | GeometryCollection<Point> | Point Collection |
line | Feature | Geometry<LineString> | Line Feature |
options? | Object | Optional parameters |
options.units? | string | unit of the output distance property (eg: degrees, radians, miles, or kilometers) (default 'kilometers') |
options.properties? | Object | Translate Properties to Point (default {}) |
Returns
Examples
var pt1 = turf.point([0, 0]);
var pt2 = turf.point([0.5, 0.5]);
var points = turf.featureCollection([pt1, pt2]);
var line = turf.lineString([
[1, 1],
[-1, 1],
]);
var nearest = turf.nearestPointToLine(points, line);
Installation
$ npm install @turf/nearest-point-to-line
import { nearestPointToLine } from "@turf/nearest-point-to-line";
const result = nearestPointToLine(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.nearestPointToLine(...);