sample
描述
¥Description
获取一个 FeatureCollection 对象,并返回一个包含随机指定数量 features 对象的 FeatureCollection。
¥Takes a FeatureCollection and returns a FeatureCollection with given number of features at random.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
fc | FeatureCollection<T> | |
num | number | 待选要素数量 |
featurecollection | FeatureCollection | 输入要素集 |
返回
¥Returns
FeatureCollection 包含 n
个要素的要素集合
¥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(...);