Skip to main content
Version: 6.5.0

mask

Description

Takes any type of polygon and an optional mask and returns a polygon exterior ring with holes.

Parameters

NameTypeDescription
polygonFeatureCollection | Feature<Polygon | MultiPolygon>GeoJSON Polygon used as interior rings or holes.
mask?Feature<Polygon>GeoJSON Polygon used as the exterior ring (if undefined, the world extent is used)

Returns

Examples

var polygon = turf.polygon([
[
[112, -21],
[116, -36],
[146, -39],
[153, -24],
[133, -10],
[112, -21],
],
]);
var mask = turf.polygon([
[
[90, -55],
[170, -55],
[170, 10],
[90, 10],
[90, -55],
],
]);

var masked = turf.mask(polygon, mask);

Installation

$ npm install @turf/mask

import { mask } from "@turf/mask";
const result = mask(...);
$ npm install @turf/turf

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