Skip to main content
Version: 7.2.0

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 多边形用作内环或孔
mask?多边形 | 特性<多边形>GeoJSON 多边形用作外环(如果未定义,则使用世界范围)
options?对象可选参数(默认 {})
options.mutate?boolean允许 mask GeoJSON 输入发生修改(如果为 true,则性能显著提升)(默认为 false)

返回

¥Returns

特性<多边形> 蒙版多边形(带孔的外环)

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