Skip to main content
Version: Next

pointOnFeature

Description

Takes a Feature or FeatureCollection and returns a Point guaranteed to be on the surface of the feature.

  • Given a Polygon, the point will be in the area of the polygon
  • Given a LineString, the point will be along the string
  • Given a Point, the point will the same as the input

Parameters

NameTypeDescription
geojsonGeoJSONany Feature or FeatureCollection

Returns

Examples

var polygon = turf.polygon([
[
[116, -36],
[131, -32],
[146, -43],
[155, -25],
[133, -9],
[111, -22],
[116, -36],
],
]);

var pointOnPolygon = turf.pointOnFeature(polygon);

Installation

$ npm install @turf/point-on-feature

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

import * as turf from "@turf/turf";
const result = turf.pointOnFeature(...);