UNPKG

1.54 kBMarkdownView Raw
1# @turf/bbox
2
3# bbox
4
5Takes 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
14var line = {
15 "type": "Feature",
16 "properties": {},
17 "geometry": {
18 "type": "LineString",
19 "coordinates": [[-74, 40], [-78, 42], [-82, 35]]
20 }
21}
22var bbox = turf.bbox(line);
23
24//addToMap
25var bboxPolygon = turf.bboxPolygon(bbox);
26var addToMap = [line, bboxPolygon]
27```
28
29Returns **[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<!-- This file is automatically generated. Please don't edit it directly:
32if 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
37This module is part of the [Turfjs project](http://turfjs.org/), an open source
38module collection dedicated to geographic algorithms. It is maintained in the
39[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
40PRs and issues.
41
42### Installation
43
44Install this module individually:
45
46```sh
47$ npm install @turf/bbox
48```
49
50Or install the Turf module that includes it as a function:
51
52```sh
53$ npm install @turf/turf
54```