Appearance
KBE3D / KBCore / turf / sample
函数: sample()
sample<
T>(fc:FeatureCollection<T>,num:number):FeatureCollection<T>
Function
Takes a FeatureCollection and returns a FeatureCollection with given number of Feature|features at random.
类型参数
T
T extends Geometry
参数
fc
num
number
number of features to select
返回
a FeatureCollection with n features
示例
ts
var points = turf.randomPoint(100, {bbox: [-80, 30, -60, 60]});
var sample = turf.sample(points, 5);
//addToMap
var addToMap = [points, sample]
turf.featureEach(sample, function (currentFeature) {
currentFeature.properties['marker-size'] = 'large';
currentFeature.properties['marker-color'] = '#000';
});