Skip to main content
Version: Next

sample

Description

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

Parameters

NameTypeDescription
fcFeatureCollection<T>
numnumbernumber of features to select
featurecollectionFeatureCollectionset of input features

Returns

FeatureCollection a FeatureCollection with n features

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(...);