@turf/point-on-feature
TypeScript icon, indicating that this package has built-in type declarations

7.1.0 • Public • Published

@turf/point-on-feature

pointOnFeature

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

  • geojson GeoJSON any Feature or FeatureCollection

Examples

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

var pointOnPolygon = turf.pointOnFeature(polygon);

//addToMap
var addToMap = [polygon, pointOnPolygon];

Returns Feature<Point> a point on the surface of input


This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.

Installation

Install this single module individually:

$ npm install @turf/point-on-feature

Or install the all-encompassing @turf/turf module that includes all modules as functions:

$ npm install @turf/turf

Package Sidebar

Install

npm i @turf/point-on-feature

Weekly Downloads

752,694

Version

7.1.0

License

MIT

Unpacked Size

28.9 kB

Total Files

9

Last publish

Collaborators

  • smallsaucepan
  • morgan.herlocker
  • twelch
  • jamesmilneruk
  • rowanwins
  • tmcw
  • morganherlocker
  • tcql
  • mdfedderly