Skip to main content
Version: 7.1.0

mask

Description

Takes polygons or multipolygons and an optional mask, and returns an exterior ring polygon with holes.

Parameters

NameTypeDescription
polygonPolygon | MultiPolygon | Feature<Polygon | MultiPolygon> | FeatureCollection<Polygon | MultiPolygon>GeoJSON polygon used as interior rings or holes
mask?Polygon | Feature<Polygon>GeoJSON polygon used as the exterior ring (if undefined, the world extent is used)
options?ObjectOptional parameters (default {})
options.mutate?booleanallows the mask GeoJSON input to be mutated (performance improvement if true) (default false)

Returns

Examples

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

const 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(...);