Atlaslog
Atlaslog / Turf.js / API / nearestPoint
Turf.js · API reference

nearestPoint

Quick answer

Takes a reference point and a FeatureCollection of Features with Point geometries and returns the point from the FeatureCollection closest to the refere.

Last verified 2026-11-03 · Turf.js 7.x · Cite this page
Runnable examplesChinese noteAll API topics

Description​

Takes a reference point and a FeatureCollection of Features with Point geometries and returns the point from the FeatureCollection closest to the reference. This calculation is geodesic.

Parameters​

NameTypeDescription
targetPointCoordthe reference point
pointsFeatureCollection<Point>against input point set
options?ObjectOptional parameters (default {})
options.units?Unitsthe units of the numeric result. Supports all valid Turf Units. (default 'kilometers')

Returns​

Feature<Point> the closest point in the set to the reference point

Examples​

var targetPoint = turf.point([28.965797, 41.010086], {
"marker-color": "#0F0",
});
var points = turf.featureCollection([
turf.point([28.973865, 41.011122]),
turf.point([28.948459, 41.024204]),
turf.point([28.938674, 41.013324]),
]);

var nearest = turf.nearestPoint(targetPoint, points);

Installation​

$ npm install @turf/nearest-point

import { nearestPoint } from "@turf/nearest-point";
const result = nearestPoint(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.nearestPoint(...);
TutorialsAPI index
English reference text adapted from the official Turf.js documentation, © Turf.js contributors, licensed under MIT.
Original page: https://turfjs.org/docs/api/nearestPoint · Chinese note: /turf/api/nearest-point.html
Cite this page

Atlaslog (2026). nearestPoint. https://www.jingweizhi.com/en/turf/api/nearest-point.html (accessed 2026-11-03).