Skip to main content
Version: Next

mask

描述

¥Description

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

参数

¥Parameters

名称类型描述
polygon多边形 | MultiPolygon | 特性<多边形 | MultiPolygon> | FeatureCollection<多边形 | MultiPolygon>GeoJSON polygon used as interior rings or holes
mask?多边形 | 特性<多边形>GeoJSON polygon used as the exterior ring (if undefined, the world extent is used)
options?对象可选参数(默认
options.mutate?booleanallows the mask GeoJSON input to be mutated (performance improvement if true) (default false)

返回

¥Returns

特性<多边形> Masked Polygon (exterior ring with holes)

¥Feature<Polygon> Masked Polygon (exterior ring with holes)

示例

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