1 | # @turf/bbox
|
2 |
|
3 | # bbox
|
4 |
|
5 | Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
|
6 |
|
7 | **Parameters**
|
8 |
|
9 | - `geojson` **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** input features
|
10 |
|
11 | **Examples**
|
12 |
|
13 | ```javascript
|
14 | var line = {
|
15 | "type": "Feature",
|
16 | "properties": {},
|
17 | "geometry": {
|
18 | "type": "LineString",
|
19 | "coordinates": [[-74, 40], [-78, 42], [-82, 35]]
|
20 | }
|
21 | }
|
22 | var bbox = turf.bbox(line);
|
23 |
|
24 | //addToMap
|
25 | var bboxPolygon = turf.bboxPolygon(bbox);
|
26 | var addToMap = [line, bboxPolygon]
|
27 | ```
|
28 |
|
29 | Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** bbox extent in [minX, minY, maxX, maxY] order
|
30 |
|
31 |
|
32 | if you find an error, edit the source file (likely index.js), and re-run
|
33 | ./scripts/generate-readmes in the turf project. -->
|
34 |
|
35 | ---
|
36 |
|
37 | This module is part of the [Turfjs project](http://turfjs.org/), an open source
|
38 | module collection dedicated to geographic algorithms. It is maintained in the
|
39 | [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
40 | PRs and issues.
|
41 |
|
42 | ### Installation
|
43 |
|
44 | Install this module individually:
|
45 |
|
46 | ```sh
|
47 | $ npm install @turf/bbox
|
48 | ```
|
49 |
|
50 | Or install the Turf module that includes it as a function:
|
51 |
|
52 | ```sh
|
53 | $ npm install @turf/turf
|
54 | ```
|