55 lines
1.6 KiB
Markdown
55 lines
1.6 KiB
Markdown
# @turf/bbox
|
|
|
|
# bbox
|
|
|
|
Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
|
|
|
|
**Parameters**
|
|
|
|
- `geojson` **([Feature](http://geojson.org/geojson-spec.html#feature-objects) \| [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects))** input features
|
|
|
|
**Examples**
|
|
|
|
```javascript
|
|
var pt1 = turf.point([114.175329, 22.2524])
|
|
var pt2 = turf.point([114.170007, 22.267969])
|
|
var pt3 = turf.point([114.200649, 22.274641])
|
|
var pt4 = turf.point([114.200649, 22.274641])
|
|
var pt5 = turf.point([114.186744, 22.265745])
|
|
var features = turf.featureCollection([pt1, pt2, pt3, pt4, pt5])
|
|
|
|
var bbox = turf.bbox(features);
|
|
|
|
var bboxPolygon = turf.bboxPolygon(bbox);
|
|
|
|
//=bbox
|
|
|
|
//=bboxPolygon
|
|
```
|
|
|
|
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
|
|
|
|
<!-- This file is automatically generated. Please don't edit it directly:
|
|
if you find an error, edit the source file (likely index.js), and re-run
|
|
./scripts/generate-readmes in the turf project. -->
|
|
|
|
---
|
|
|
|
This module is part of the [Turfjs project](http://turfjs.org/), an open source
|
|
module collection dedicated to geographic algorithms. It is maintained in the
|
|
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
|
|
PRs and issues.
|
|
|
|
### Installation
|
|
|
|
Install this module individually:
|
|
|
|
```sh
|
|
$ npm install @turf/bbox
|
|
```
|
|
|
|
Or install the Turf module that includes it as a function:
|
|
|
|
```sh
|
|
$ npm install @turf/turf
|
|
```
|