bbox
Description
Calculates the bounding box for any GeoJSON object, including FeatureCollection. Uses geojson.bbox if available and options.recompute is not set.
Parameters
Name | Type | Description |
---|---|---|
geojson | GeoJSON | any GeoJSON object |
options? | Object | Optional parameters (default {}) |
options.recompute? | boolean | Whether to ignore an existing bbox property on geojson |
Returns
BBox bbox extent in [minX, minY, maxX, maxY] order
Examples
var line = turf.lineString([
[-74, 40],
[-78, 42],
[-82, 35],
]);
var bbox = turf.bbox(line);
var bboxPolygon = turf.bboxPolygon(bbox);
Installation
$ npm install @turf/bbox
import { bbox } from "@turf/bbox";
const result = bbox(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.bbox(...);