1 | # turf-sample
|
2 |
|
3 | [![build status](https://secure.travis-ci.org/Turfjs/turf-sample.png)](http://travis-ci.org/Turfjs/turf-sample)
|
4 |
|
5 | turf sample module
|
6 |
|
7 |
|
8 | ### `turf.sample(features, n)`
|
9 |
|
10 | Takes a FeatureCollection and returns a FeatureCollection with given number of Feature|features at random.
|
11 |
|
12 |
|
13 | ### Parameters
|
14 |
|
15 | | parameter | type | description |
|
16 | | ---------- | ----------------- | ---------------------------- |
|
17 | | `features` | FeatureCollection | set of input features |
|
18 | | `n` | Number | number of features to select |
|
19 |
|
20 |
|
21 | ### Example
|
22 |
|
23 | ```js
|
24 | var points = turf.random('points', 1000);
|
25 |
|
26 | //=points
|
27 |
|
28 | var sample = turf.sample(points, 10);
|
29 |
|
30 | //=sample
|
31 | ```
|
32 |
|
33 |
|
34 | **Returns** `FeatureCollection`, a FeatureCollection with `n` features
|
35 |
|
36 | ## Installation
|
37 |
|
38 | Requires [nodejs](http://nodejs.org/).
|
39 |
|
40 | ```sh
|
41 | $ npm install turf-sample
|
42 | ```
|
43 |
|
44 | ## Tests
|
45 |
|
46 | ```sh
|
47 | $ npm test
|
48 | ```
|
49 |
|
50 |
|