Skip to main content
Version: Next

bboxClip

Description

Takes a Feature and a bbox and clips the feature to the bbox using lineclip. May result in degenerate edges when clipping Polygons.

Parameters

NameTypeDescription
featureFeature<LineString | MultiLineString | Polygon | MultiPolygon>feature to clip to the bbox
bboxBBoxextent in [minX, minY, maxX, maxY] order

Returns

Examples

var bbox = [0, 0, 10, 10];
var poly = turf.polygon([
[
[2, 2],
[8, 4],
[12, 8],
[3, 7],
[2, 2],
],
]);

var clipped = turf.bboxClip(poly, bbox);

Installation

$ npm install @turf/bbox-clip

import { bboxClip } from "@turf/bbox-clip";
const result = bboxClip(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.bboxClip(...);