Skip to main content
Version: 6.5.0

sample

Description

Takes a FeatureCollection and returns a FeatureCollection with given number of features at random.

Parameters

NameTypeDescription
featurecollectionFeatureCollectionset of input features
numnumbernumber of features to select

Returns

Examples

var points = turf.randomPoint(100, { bbox: [-80, 30, -60, 60] });

var sample = turf.sample(points, 5);

Installation

$ npm install @turf/sample

import { sample } from "@turf/sample";
const result = sample(...);
$ npm install @turf/turf

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